Viewing SAS Libraries

Viewing Libraries

Besides accessing library details with librefs, you can also see libraries in other environments. You can access a brief overview on the windows and menus of the SAS windowing environment, Enterprise Guide, and SAS Studio at http://video.sas.com/. From Categories select How To Tutorials>Programming. Select the video for your SAS environment. Other tutorials are available from the SAS website.

Viewing Libraries Using PROC CONTENTS

You can use the CONTENTS procedure to create SAS output that describes either of the following:
  • the contents of a library
  • the descriptor information for an individual SAS data set
Syntax, PROC CONTENTS step:
PROC CONTENTS DATA=SAS-file-specification NODS;
RUN;
  • SAS-file-specification specifies an entire library or a specific SAS data set within a library. SAS-file-specification can take one of the following forms:
    • <libref.>SAS-data-set names one SAS data set to process.
    • <libref.>_ALL_ requests a listing of all files in the library. (Use a period (.) to append _ALL_ to the libref.)
  • NODS suppresses the printing of detailed information about each file when you specify _ALL_. (You can specify NODS only when you specify _ALL_.)

Examples: PROC CONTENTS Output

To view the contents of the entire clinic library, you can submit the following PROC CONTENTS step:
proc contents data=medical._all_ nods;run;
The output from this step lists only the names, types, sizes, and modification dates for the SAS files in the Medical library.
Figure 3.2 PROC CONTENTS Output: the SAS Library Medical (partial output)
Partial Output from PROC CONTENTS on SAS Library Medical
To view the descriptor information for only the medical.Lesions data set, you can submit the following PROC CONTENTS step:
proc contents data=medical.lesions; 
run;
The output from this step lists information for medical.Lesions, including an alphabetic list of the variables in the data set.
Figure 3.3 PROC CONTENTS Output: Descriptor Information
PROC CONTENTS Output Showing the Descriptor Information for a Single Data Set in a Library
Figure 3.4 PROC CONTENTS Output: Engine/Host Dependent Information
PROC CONTENTS Output Showing the Engine/Host Dependent Information for a Single Data Set in a Library
Figure 3.5 PROC CONTENTS Output: Alphabetic List of Variables
PROC CONTENTS Output Showing an Alphabetic List of the Variables in the Data Set

Viewing Libraries Using PROC DATASETS

In addition to PROC CONTENTS, you can use PROC DATASETS to view the contents of a SAS library or a SAS data set. PROC DATASETS also enables you to perform a number of management tasks such as copying, deleting, or modifying SAS files.
PROC CONTENTS and PROC DATASETS overlap in terms of functionality. Generally, the following are the same:
  • the CONTENTS procedure
  • the CONTENTS statement in the DATASETS procedure
PROC CONTENTS<options>;
RUN;
PROC DATASETS<options>;
CONTENTS<options>;
QUIT;
Here is the major difference between the CONTENTS procedure and the CONTENTS statement in PROC DATASETS:
  • The default value for libref in the DATA= option. For PROC CONTENTS, the default is either Work or User depending on your SAS solution or environment. For the CONTENTS statement, the default is the libref of the procedure input library.
    Note: PROC DATASETS supports RUN-group processing. It uses a QUIT statement to end the procedure.
However, the options for the PROC CONTENTS statement and the CONTENTS statement in the DATASETS procedure are the same. For example, the following PROC steps produce essentially the same output (with minor formatting differences):
proc datasets; 
   contents data=medical._all_ nods; 

proc contents data=medical._all_ nods; 
run;
Figure 3.6 PROC DATASETS Output: Directory Information
Directory Information
Figure 3.7 PROC DATASETS Output: Library Members (partial output)
Partial Output: PROC DATASETS Library Members
Figure 3.8 PROC CONTENTS Output: Directory Information
Directory Information
Figure 3.9 PROC CONTENTS Output: Library Members (partial output)
Library Members

Viewing Data Set Descriptor Information Using PROC DATASETS and the VARNUM Option

As with PROC CONTENTS, you can also use PROC DATASETS to display the descriptor information for a specific SAS data set.
By default, PROC CONTENTS and PROC DATASETS list variables alphabetically. To list variable names in the order of their logical position (or creation order) in the data set, specify the VARNUM option in PROC CONTENTS or in the CONTENTS statement in PROC DATASETS.
For example, either of these programs creates output that includes the list of variables shown below:
proc datasets; 
   contents data=medical.Lesions varnum; 

proc contents data=medical.Lesions varnum; 
run;
Figure 3.10 Viewing Descriptor Information for a SAS Data Set Using VARNUM
Viewing Descriptor Information for a SAS Data Set Using VARNUM
Last updated: January 10, 2018
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.179.225