Previous Page | Next Page

Getting Information about Your SAS Data Sets

Requesting Contents Information about SAS Data Sets


Using the DATASETS Procedure for SAS Data Sets

To look at the contents of a SAS data set without displaying the observations, use the CONTENTS statement in the DATASETS procedure. The CONTENTS statement and its options provide descriptive information about data sets and a list of variables and their attributes.


Listing the Contents of One Data Set

The SAS data library USCLIM contains four data sets, with the data set TEMPCHNG containing data for extreme changes in temperature. The following program displays the variables in the data set TEMPCHNG:

proc datasets library=usclim memtype=data;
   contents data=tempchng;
run;

The CONTENTS statement produces a contents listing, and the DATA= option specifies the name of the data set. The following output shows the results from the CONTENTS statement, which are sent to SAS output rather than to the SAS log. Note that output from the CONTENTS statement varies for different operating environments.

Contents Listing for the Data Set TEMPCHNG

                                 The SAS System

                             The DATASETS Procedure 1 

Data Set Name: USCLIM.TEMPCHNG                          Observations:         5 
Member Type:   DATA                                     Variables:            6 
Engine:        V8                                       Indexes:              0 
Created:       14:32 Wednesday, November 15, 2000       Observation Length:   56
Last Modified: 14:32 Wednesday, November 15, 2000       Deleted Observations: 0 
Protection:                                             Compressed:           NO
Data Set Type:                                          Sorted:               NO
Label:                                                                          


                  -----Engine/Host Dependent Information----- 2 

      Data Set Page Size:         8192                                    
      Number of Data Set Pages:   1                                       
      First Data Page:            1                                       
      Max Obs per Page:           145                                     
      Obs in First Data Page:     5                                       
      Number of Data Set Repairs: 0                                       
      File Name:                  /u/userid/usclim/tempchng.sas7bdat
      Release Created:            8.0202M0                                
      Host Created:               HP-UX                                   
      Inode Number:               14595                                   
      Access Permission:          rw-r--r--                               
      Owner Name:                 userid                                  
      File Size (bytes):          16384                                   


             -----Alphabetic List of Variables and Attributes----- 3 
 
           #    Variable    Type    Len    Pos    Format    Informat
           ---------------------------------------------------------
           2    Date        Num       8      0    DATE9.    DATE7.  
           6    Diff        Num       8     32                      
           4    End_f       Num       8     16                      
           5    Minutes     Num       8     24                      
           3    Start_f     Num       8      8                      
           1    State       Char     13     40              $CHAR13.

The following list describes information that you might find in contents listing and corresponds to the numbered items in the preceding output:

[1] Heading

contains field names. Fields are empty if they do not apply to the data set. Field names are listed below:

Data Set Name

is the two-level name that is assigned to the data set.

Member Type

is the type of library member.

Engine

is the access method that SAS uses to read from or write to the data set.

Created

is the date that the data set was created.

Last Modified

is the last date that the data set was modified.

Protection

indicates whether the data set is password protected for READ, WRITE, or ALTER operations.

Data Set Type

applies only to files with the member type DATA. Information in this field indicates that the data set contains special observations and variables for use with SAS statistical procedures.

Label

is the descriptive information that you supply in a LABEL= data set option to identify the data set.

Observations

is the total number of observations currently in the data set.

Variables

is the number of variables in the data set.

Indexes

is the number of indexes for the data set.

Observation Length

is the length of each observation in bytes.

Deleted Observations

is the number of observations marked for deletion, if applicable.

Compressed

indicates whether the data is in fixed-length or variable-length records. If the data set is compressed, then additional fields indicate whether new observations are added to the end of the data set or written to unused space within the data set and whether the data set can be randomly accessed by observation number rather than sequential access only.

Sorted

indicates whether the data set has been sorted.

[2] Engine/Host Dependent Information

lists information about the engine, which is the mechanism for reading from and writing to files, and about how the data set is stored by the operating environment. Depending on the engine, the output in this section might differ. For more information, see the SAS documentation for your operating environment.

[3] Alphabetical List of Variables and Attributes

lists all the variable names in the data set in alphabetical order and describes the attributes that are assigned to the variable when it is defined. The attributes are described below:

#

is the logical position of the variable in the observation. This is the number that is assigned to the variable when it is defined.

Variable

is the name of the variable.

Type

indicates whether the variable is character or numeric.

Len

is the length of the variable in bytes.

Pos

is the physical position in the observation buffer of the first byte of the variable's associated value.

Format

is the format of the variable.

Informat

is the informat of the variable.

In addition, if applicable, the output also displays a table that describes the following information:


Listing the Contents of All Data Sets in a Library

You can list the contents of all the data sets in a library by specifying the keyword _ALL_ with the DATA= option. The following statements produce a directory listing in SAS output for the library and a contents listing for each data set in the directory:

   contents data=_all_;
run;

To send only a directory listing to SAS output, add the NODS option. The following statements produce a directory listing but suppress a contents listing for individual data sets. Use this form if you want the directory listing for the procedure input library:

   contents data=_all_ nods;
run;

Include the libref if you want the directory listing for another library. This example specifies the library STORM:

   contents data=storm._all_ nods;
run;

Previous Page | Next Page | Top of Page