Base SAS 9.1 Procedures Guide, Volumes 1, 2, 3 and 4

Directory Listing to the SAS Log

The PROC DATASETS statement lists the SAS files in the procedure input library unless the NOLIST option is specified. The NOLIST option prevents the creation of the procedure results that go to the log. If you specify the MEMTYPE= option, only specified types are listed. If you specify the DETAILS option, PROC DATASETS prints these additional columns of information: Obs, Entries or Indexes , Vars , and Label .

Directory Listing as SAS Output

The CONTENTS statement lists the directory of the procedure input library if you use the DIRECTORY option or specify DATA=_ALL_.

If you want only a directory, use the NODS option and the _ALL_ keyword in the DATA= option. The NODS option suppresses the description of the SAS data sets; only the directory appears in the output.

Note: The CONTENTS statement does not put a directory in an output data set. If you try to create an output data set using the NODS option, you receive an empty output data set. Use the SQL procedure to create a SAS data set that contains information about a SAS data library.

Note: If you specify the ODS RTF destination, the PROC DATASETS output will go to both the SAS log and the ODS output area. The NOLIST option will suppress output to both. To see the output only in the SAS log, use the ODS EXCLUDE statement by specifying the member directory as the exclusion.

Procedure Output

The CONTENTS Statement

The only statement in PROC DATASETS that produces procedure output is the CONTENTS statement. This section shows the output from the CONTENTS statement for the GROUP data set, which is shown in Output 15.3.

Output 15.3: Data Set Attributes for the GROUP Data Set

The SAS System 1 The DATASETS Procedure Data Set Name HEALTH.GROUP Observations 148 Member Type DATA Variables 11 Engine V9 Indexes 1 Created Wednesday, February Observation Length 96 05, 2003 02:20:56 Last Modified Wednesday, February Deleted Observations 0 05, 2003 02:20:56 Protection READ Compressed NO Data Set Type Sorted YES Label Test Subjects Data Representation WINDOWS_32 Encoding wlatin1 Western (Windows)

 

Only the items in the output that require explanation are discussed.

Data Set Attributes

Here are descriptions of selected fields shown in Output 15.3:

Member Type

Protection

Data Set Type

Observations

Deleted Observations

Compressed

Sorted

Data Representation

Encoding

Engine and Operating Environment-Dependent Information

The CONTENTS statement produces operating environment-specific and engine-specific information. This information differs depending on the operating environment. The following output is from the Windows operating environment.

Output 15.4: Engine and Operating Environment Dependent Information Section of CONTENTS Output

Engine/Host Dependent Information Data Set Page Size 8192 Number of Data Set Pages 4 First Data Page 1 Max Obs per Page 84 Obs in First Data Page 62 Index File Page Size 4096 Number of Index File Pages 2 Number of Data Set Repairs 0 File Name c:\Myfiles\health\group.sas7bdat Release Created 9.0101B0 Host Created XP_PRO

 

Alphabetic List of Variables and Attributes

Here are descriptions of selected columns in Output 15.5:

#

Variable

Type

Len

Transcode

Output 15.5: Variable Attributes Section

Alphabetic List of Variables and Attributes # Variable Type Len Format Informat Label Transcode 9 BIRTH Num 8 DATE7. DATE7. YES 4 CITY Char 15 $. $. NO 3 FNAME Char 15 $. $. NO 10 HIRED Num 8 DATE7. DATE7. YES 11 HPHONE Char 12 $. $. YES 1 IDNUM Char 4 $. $. YES 7 JOBCODE Char 3 $. $. YES 2 LNAME Char 15 $. $. YES 8 SALARY Num 8 COMMA8. current salary excluding bonus YES 6 SEX Char 1 $. $. YES 5 STATE Char 2 $. $. YES

 

Note: If none of the variables in the SAS data set has a format, informat, or label associated with it, or if none of the variables are set to no transcoding, then the column for that attribute does not display.

Alphabetic List of Indexes and Attributes

The section shown in Output 15.6 appears only if the data set has indexes associated with it.

Output 15.6: Index Attributes Section

Alphabetic List of Indexes and Attributes # of Unique NoMiss Unique # Index Option Option Values Variables 1 vital YES YES 148 BIRTH SALARY

 

#

Index

Unique Option

Nomiss Option

# of Unique Values

Variables

Sort Information

The section shown in Output 15.7 appears only if the Sorted field has a value of YES.

Output 15.7: Sort Information Section

The SAS System 2 The DATASETS Procedure Sort Information Sortedby LNAME Validated NO Character Set ANSI

 

Sortedby

Validated

Character Set

Collating Sequence

Sort Option

PROC DATASETS and the Output Delivery System (ODS)

Most SAS procedures send their messages to the SAS log and their procedure results to the output. PROC DATASETS is unique because it sends procedure results to both the SAS log and the procedure output file. When the interface to ODS was created, it was decided that all procedure results (from both the log and the procedure output file) should be available to ODS. In order to implement this feature and maintain compatibility with earlier releases, the interface to ODS had to be slightly different from the usual interface.

By default, the PROC DATASETS statement itself produces two output objects: Members and Directory. These objects are routed to the SAS log. The CONTENTS statement produces three output objects by default: Attributes, EngineHost, and Variables. (The use of various options adds other output objects.) These objects are routed to the procedure output file. If you open an ODS destination (such as HTML, RTF, or PRINTER), all of these objects are, by default, routed to that destination.

You can use ODS SELECT and ODS EXCLUDE statements to control which objects go to which destination, just as you can for any other procedure. However, because of the unique interface between PROC DATASETS and ODS, when you use the keyword LISTING in an ODS SELECT or ODS EXCLUDE statement, you affect both the log and the listing.

ODS Table Names

PROC DATASETS and PROC CONTENTS assign a name to each table they create. You can use these names to reference the table when using the Output Delivery System (ODS) to select tables and create output data sets. For more information, see The Complete Guide to the SAS Output Delivery System .

PROC CONTENTS generates the same ODS tables as PROC DATASETS with the CONTENTS statement.

Table 15.6: ODS Tables Produced by the DATASETS Procedure without the CONTENTS Statement

ODS Table

Description

Table is generated:

Directory

General library information

unless you specify the NOLIST option.

Members

Library member information

unless you specify the NOLIST option.

Table 15.7: ODS Table Names Produced by PROC CONTENTS and PROC DATASETS with the CONTENTS Statement

ODS Table

Description

Table is generated:

Attributes

Data set attributes

unless you specify the SHORT option.

Directory

General library information

if you specify DATA=< libref .>_ALL_ or the DIRECTORY option. [*]

EngineHost

Engine and operating environment information

unless you specify the SHORT option.

IntegrityConstraints

A detailed listing of integrity constraints

if the data set has integrtiy constraints and you do not specify the SHORT option.

IntegrityConstraintsShort

A concise listing of integrity constraints

if the data set has integrity constraints and you specify the SHORT option

Indexes

A detailed listing of indexes

if the data set is indexed and you do not specify the SHORT option.

IndexesShort

A concise listing of indexes

if the data set is indexed and you specify the SHORT option.

Members

Library member information

if you specify DATA=< libref .>_ALL_ or the DIRECTORY option. [*]

Position

A detailed listing of variables by logical position in the data set

if you specify the VARNUM option and you do not specify the SHORT option.

PositionShort

A concise listing of variables by logical position in the data set

if you specify the VARNUM option and the SHORT option.

Sortedby

Detailed sort information

if the data set is sorted and you do not specify the SHORT option.

SortedbyShort

Concise Sort information

if the data set is sorted and you specify the SHORT option.

Variables

A detailed listing of variables in alphabetical order

unless you specify the SHORT option.

VariablesShort

A concise listing of variables in alphabetical order

if you specify the SHORT option.

[*] For PROC DATASETS, if both the NOLIST option and either the DIRECTORY option or DATA= < libref. >_ALL_ are specified, then the NOLIST option is ignored.

[*] For PROC DATASETS, if both the NOLIST option and either the DIRECTORY option or DATA=< libref. >_ALL_ are specified, then the NOLIST option is ignored.

Output Data Sets

The CONTENTS Statement

The CONTENTS statement is the only statement in the DATASETS procedure that generates output data sets.

The OUT= Data Set

The OUT= option in the CONTENTS statement creates an output data set. Each variable in each DATA= data set has one observation in the OUT= data set. These are the variables in the output data set:

The output data set is sorted by the variables LIBNAME and MEMNAME.

Note: The variable names are sorted so that the values X1, X2, and X10 are listed in that order, not in the true collating sequence of X1, X10, X2. Therefore, if you want to use a BY statement on MEMNAME in subsequent steps, run a PROC SORT step on the output data set first or use the NOTSORTED option in the BY statement.

The following is an example of an output data set created from the GROUP data set, which is shown in Example 4 on page 381 and in Procedure Output on page 360.

Output 15.8: The Data Set HEALTH.GRPOUT

An Example of an Output Data Set 1 OBS LIBNAME MEMNAME MEMLABEL TYPEMEM NAME TYPE LENGTH VARNUM 1 HEALTH GROUP Test Subjects BIRTH 1 8 9 2 HEALTH GROUP Test Subjects CITY 2 15 4 3 HEALTH GROUP Test Subjects FNAME 2 15 3 4 HEALTH GROUP Test Subjects HIRED 1 8 10 5 HEALTH GROUP Test Subjects HPHONE 2 12 11 6 HEALTH GROUP Test Subjects IDNUM 2 4 1 7 HEALTH GROUP Test Subjects JOBCODE 2 3 7 8 HEALTH GROUP Test Subjects LNAME 2 15 2 9 HEALTH GROUP Test Subjects SALARY 1 8 8 10 HEALTH GROUP Test Subjects SEX 2 1 6 11 HEALTH GROUP Test Subjects STATE 2 2 5 OBS LABEL FORMAT FORMATL FORMATD INFORMAT INFORML 1 DATE 7 0 DATE 7 2 $ 0 0 $ 0 3 $ 0 0 $ 0 4 DATE 7 0 DATE 7 5 $ 0 0 $ 0 6 $ 0 0 $ 0 7 $ 0 0 $ 0 8 $ 0 0 $ 0 9 current salary excluding bonus COMMA 8 0 0 10 $ 0 0 $ 0 11 $ 0 0 $ 0 An Example of an Output Data Set 2 Obs INFORMD JUST NPOS NOBS ENGINE CRDATE MODATE DELOBS 1 0 1 8 148 V9 29JAN02:08:06:46 29JAN02:09:13:36 0 2 0 0 58 148 V9 29JAN02:08:06:46 29JAN02:09:13:36 0 3 0 0 43 148 V9 29JAN02:08:06:46 29JAN02:09:13:36 0 4 0 1 16 148 V9 29JAN02:08:06:46 29JAN02:09:13:36 0 5 0 0 79 148 V9 29JAN02:08:06:46 29JAN02:09:13:36 0 6 0 0 24 148 V9 29JAN02:08:06:46 29JAN02:09:13:36 0 7 0 0 76 148 V9 29JAN02:08:06:46 29JAN02:09:13:36 0 8 0 0 28 148 V9 29JAN02:08:06:46 29JAN02:09:13:36 0 9 0 1 0 148 V9 29JAN02:08:06:46 29JAN02:09:13:36 0 10 0 0 75 148 V9 29JAN02:08:06:46 29JAN02:09:13:36 0 11 0 0 73 148 V9 29JAN02:08:06:46 29JAN02:09:13:36 0 OBS IDXUSAGE MEMTYPE IDXCOUNT PROTECT FLAGS COMPRESS REUSE SORTED SORTEDBY 1 COMPOSITE DATA 1 R-- --- NO NO 0 . 2 NONE DATA 1 R-- --- NO NO 0 . 3 NONE DATA 1 R-- --- NO NO 0 . 4 NONE DATA 1 R-- --- NO NO 0 . 5 NONE DATA 1 R-- --- NO NO 0 . 6 NONE DATA 1 R-- --- NO NO 0 . 7 NONE DATA 1 R-- --- NO NO 0 . 8 NONE DATA 1 R-- --- NO NO 0 1 9 COMPOSITE DATA 1 R-- --- NO NO 0 . 10 NONE DATA 1 R-- --- NO NO 0 . 11 NONE DATA 1 R-- --- NO NO 0 . An Example of an Output Data Set 3 OBS CHARSET COLLATE NODUPKEY NODUPREC ENCRYPT POINTOBS GENMAX GENNUM GENNEXT 1 ANSI NO NO NO YES 0 . . 2 ANSI NO NO NO YES 0 . . 3 ANSI NO NO NO YES 0 . . 4 ANSI NO NO NO YES 0 . . 5 ANSI NO NO NO YES 0 . . 6 ANSI NO NO NO YES 0 . . 7 ANSI NO NO NO YES 0 . . 8 ANSI NO NO NO YES 0 . . 9 ANSI NO NO NO YES 0 . . 10 ANSI NO NO NO YES 0 . . 11 ANSI NO NO NO YES 0 . .

 

Note: For information about how to get the CONTENTS output into an ODS data set for processing, see Example 7 on page 386.

The OUT2= Data Set

The OUT2= option in the CONTENTS statement creates an output data set that contains information about indexes and integrity constraints. These are the variables in the output data set:

Категории