Now that you’ve defined the ntrhd library, you want to see what’s in the library.
You can write a SAS program that creates a report containing information about the library and the files it contains.
In this demonstration you will run the contents procedure to view the contents of the ntrhd library.
Like any procedure, we will begin by typing PROC, and then the SAS keyword CONTENTS.
We will tell SAS to perform this procedure on the data contained in the library called ntrdh,
but instead of referenceing a specific SAS data set after the period we will use the SAS keyword _all_ after the period.
This tells SAS that we want to view the general information about the library and list all the members of the library.
The resulting report displays general information about the library including the LIBREF and the physical location of the file in the directory table.
It also has a table that displays the members of the library in alphabetical order.
Below that is a listing of the descriptor portions of the individual data sets.
We will talk about those later.
But, if there are many data sets in the library, this section can be very lengthy.
If you only want to see the general information and table of members for the library,
you can include the NODS option to the PROC statement as is done in this example.
Here the descriptor portion of the individual data sets has been suppressed in the output.
A brief note on SAS data sets.
SAS data sets actually have two distinct parts: a data portion and a descriptor portion.
The data portion is pretty self explanatory,
and you have already viewed the data portion of SAS datasets using the PRINT procedure and the viewtable window.
The descriptor portion is where SAS saves information about the attributes of the data set such as:
the name of the data set,
and the date it was created.
The descriptor portion also contains information about each variable such as: the storage length, type, labels, and formats.
You can use the CONTENTS procedure to view the descriptor portion of the SAS data set.
Now let’s run the contents procedure again.
This time to view the descriptor portion of the height_and_weight data set.
Notice that this time, after the keyword data, we give the two-level data set name for the data set of interest instead of the LIBREF and _all_.
The report generated by PROC CONTENTS gives us lots of information such as the data set name,
when it was created, how many observations it contains, and how many variables it contains.
At the bottom of the report there is a table that has all the variables list alphabetically along with the variables’ attributes.
But let’s say you want to see a list of all variables in the order they appear in the data set, as opposed to alphabetical order.
All you have to do is add the VARNUM option to your PROC statement like so…
And now you see them in order.
This is another one of those procedures that isn’t all that useful with the small data sets we are currently using,
but they may be helpful to you as you begin working with larger data sets.
You now know two ways to create libraries in SAS and permanently store SAS data sets.
You also know two different SAS procedures for viewing the two different parts of a SAS data set: PROC PRINT and PROC CONTENTS.
If you feel comfortable with the material covered in this lecture, please move on to the lecture that covers importing data into SAS.