How to View the Contents of SAS Libraries of SAS Files

To View the Contents of SAS Libraries or SAS Files – use CONTENTS Procedure.

CONTENTS Procedure for Libraries – In SAS University Edition, SASHELP Library exists by default. Shown below is a basic PROC CONTENTS step, where, _ALL_ requests a listing of all files in the  sashelp library. We used a period (.) to append _ALL_ to the library. NODS or NODETAILS  restricts the printing of detailed information about each file.


CONTENTS Procedure for Files – is used to descriptor information for a data set. In the following example we will view descriptor information for BMT data set in SASHELP Library:


The output from PROC CONTENTS step lists information for sashelp.bmt, including an alphabetic list of the variables in the data set.

We can also use DATASETS Procedure with CONTENTS Statement to view the contents of a SAS library or a SAS data set. In the following example, CONTENTS statement lists the contents data sets in sashelp library and prints its directory.


In the following example, CONTENTS describes the contents of BMT data set and displays an alphabetic list of the variables in the data set.


Both PROC CONTENTS and PROC DATASETS, by default, list variables alphabetically. We can specify the VARNUM option in PROC CONTENTS or in the CONTENTS statement in PROC DATASETS to list variable names in their original order in the data set.

List of Variable names listed with VARNUM option:results_sasMajor difference between CONTENTS Procedure and DATASETS Procedure with CONTENTS Statement:

PROC DATASETS uses several other statements in  addition to the CONTENTS statement. These statements enable us to perform tasks that PROC CONTENTS does not perform.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s