The DATASETS Procedure |
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 library.
Note: If you specify the ODS RTF destination, the PROC DATASETS output goes to both the SAS log and the ODS output area. The NOLIST option suppresses 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 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 the following output.
Only the items in the output that require explanation are discussed.
Here are descriptions of selected fields shown in the following output:
is the type of library member (DATA or VIEW).
indicates whether the SAS data set is READ, WRITE, or ALTER password protected.
names the special data set type (such as CORR, COV, SSPC, EST, or FACTOR), if any.
is the total number of observations currently in the file. Note that for a very large data set, if the number of observations exceeds the largest integer value that can be represented in a double precision floating point number, the count is shown as missing.
is the number of observations marked for deletion. These observations are not included in the total number of observations, shown in the Observations field. Note that for a very large data set, if the number of deleted observations exceeds the number that can be stored in a double-precision integer, the count is shown as missing. Also, the count for Deleted Observations shows a missing value if you use the COMPRESS=YES option with one or both of the REUSE=YES and POINTOBS=NO options.
indicates whether the data set is compressed. If the data set is compressed, the output includes an additional item, Reuse Space (with a value of YES or NO). This item indicates whether to reuse space that is made available when observations are deleted.
indicates whether the data set is sorted. If you sort the data set with PROC SORT, PROC SQL, or specify sort information with the SORTEDBY= data set option, a value of YES appears here, and there is an additional section to the output. See Sort Information for details.
is the format in which data is represented on a computer architecture or in an operating environment. For example, on an IBM PC, character data is represented by its ASCII encoding and byte-swapped integers. Native data representation refers to an environment for which the data representation compares with the CPU that is accessing the file. For example, a file that is in Windows data representation is native to the Windows operating environment.
is the encoding value. Encoding is a set of characters (letters, logograms, digits, punctuation, symbols, control characters, and so on) that have been mapped to numeric values (called code points) that can be used by computers. The code points are assigned to the characters in the character set when you apply an encoding method.
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 0 Created Wed, Sep 12, 2007 01:57:49 PM Observation Length 96 Last Modified Wed, Sep 12, 2007 01:57:49 PM Deleted Observations 0 Protection Compressed NO Data Set Type Sorted NO Label Data Representation WINDOWS_32 Encoding wlatin1 Western (Windows)
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.
Engine and Operating Environment Dependent Information Section of CONTENTS Output
Engine/Host Dependent Information Data Set Page Size 8192 Number of Data Set Pages 3 First Data Page 1 Max Obs per Page 84 Obs in First Data Page 63 Number of Data Set Repairs 0 Filename \myfiles\health\group.sas7bdat Release Created 9.0201B0 Host Created XP_PRO
Here are descriptions of selected columns in the following output:
is the logical position of each variable in the observation. This number is assigned to the variable when the variable is defined.
is the name of each variable. By default, variables appear alphabetically.
Note: Variable names are sorted such that X1, X2, and X10 appear in that order and not in the true collating sequence of X1, X10, and X2. Variable names that contain an underscore and digits might appear in a nonstandard sort order. For example, P25 and P75 appear before P2_5.
specifies the type of variable: character or numeric.
specifies the variable's length, which is the number of bytes used to store each of a variable's values in a SAS data set.
specifies whether a character variable is transcoded. If the attribute is NO, then transcoding is suppressed. By default, character variables are transcoded when required. For more information on transcoding, see SAS National Language Support (NLS): Reference Guide.
Note: If none of the variables in the SAS data set has a format, informat, or label associated with it, or if all of the variables are set to TRANSCODE=YES, then the column for the attribute is NOT displayed.
Alphabetic List of Variables and Attributes # Variable Type Len Format Informat 9 BIRTH Num 8 4 CITY Char 15 3 FNAME Char 15 10 HIRED Num 8 DATE7. DATE7. 11 HPHONE Char 12 1 IDNUM Char 4 7 JOBCODE Char 4 2 LNAME Char 15 8 SALARY Num 8 COMMA8. 6 SEX Char 2 5 STATE Char 3
The section shown in the following output appears only if the data set has indexes associated with it.
indicates the number of each index. The indexes are numbered sequentially as they are defined.
displays the name of each index. For simple indexes, the name of the index is the same as a variable in the data set.
indicates whether the index must have unique values. If the column contains YES, the combination of values of the index variables is unique for each observation.
indicates whether the index excludes missing values for all index variables. If the column contains YES, the index does not contain observations with missing values for all index variables.
gives the number of unique values in the index.
names the variables in a composite index.
Alphabetic List of Indexes and Attributes # of Unique NoMiss Unique # Index Option Option Values Variables 1 vital YES YES 148 BIRTH SALARY
The section shown in the following output appears only if the Sorted field has a value of YES.
indicates how the data are currently sorted. This field contains either the variables and options you use in the BY statement in PROC SORT, the column name in PROC SQL, or the values you specify in the SORTEDBY= option.
indicates whether the data was sorted using PROC SORT or SORTEDBY. If PROC SORT or PROC SQL sorted the data set, the value is YES. If you assigned the sort indicator with the SORTEDBY= data set option, the value is NO.
is the character set used to sort the data. The value for this field can be ASCII, EBCDIC, or PASCII.
is the collating sequence used to sort the data set, which can be a translation table name, an encoding value, or LINGUISTIC if the data set is sorted linguistically. This field does not appear if you do not specify a collating sequence that is different from the character set.
If the data set is sorted linguistically, additional linguistic collation sequence information displays after Collating Sequence, such as the locale, collation style, and so on. For a list of the collation rules that can be specified for linguistic collation, see the SORTSEQ= option in the PROC SORT Statement in the SORT procedure.
indicates whether PROC SORT used the NODUPKEY or NODUPREC option when sorting the data set. This field does not appear if you did not use one of these options in a PROC SORT statement. (not shown)
Sort Information Sortedby LNAME Validated YES Character Set ANSI Collating Sequence LINGUISTIC Locale en_US Strength 3
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.
PROC CONTENTS generates the same ODS tables as PROC DATASETS with the CONTENTS statement.
ODS Table | Description | Generates Table |
---|---|---|
Directory | General library information | unless you specify the NOLIST option. |
Members | Library member information | unless you specify the NOLIST option. |
ODS Table | Description | Generates Table |
---|---|---|
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 integrity 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. |
Output Data Sets |
The CONTENTS statement is the only statement in the DATASETS procedure that generates output data sets.
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. Here are the variables in the output data set:
the character set used to sort the data set. The value is ASCII, EBCDIC, or PASCII. A blank appears if the data set does not have a sort indicator stored with it.
the collating sequence used to sort the data set. A blank appears if the sort indicator for the input data set does not include a collating sequence.
indicates whether the data set is compressed.
date the data set was created.
number of observations marked for deletion in the data set. (Observations can be marked for deletion but not actually deleted when you use the FSEDIT procedure of SAS/FSP software.)
indicates whether the data set is encrypted.
name of the method used to read from and write to the data set.
indicates whether the variables in an SQL view are protected (P) or contribute (C) to a derived variable.
P |
indicates the variable is protected. The value of the variable can be displayed but not updated. |
C |
indicates whether the variable contributes to a derived variable. |
The value of FLAG is blank if P or C does not apply to an SQL view or if it is a data set view.
variable format. The value of FORMAT is a blank if you do not associate a format with the variable.
number of decimals you specify when you associate the format with the variable. The value of FORMATD is 0 if you do not specify decimals in the format.
format length. If you specify a length for the format when you associate the format with a variable, the length you specify is the value of FORMATL. If you do not specify a length for the format when you associate the format with a variable, the value of FORMATL is the default length of the format if you use the FMTLEN option and 0 if you do not use the FMTLEN option.
maximum number of versions for the generation group.
the next generation number for a generation group.
the version number.
number of indexes for the data set.
use of the variable in indexes. Possible values are
the variable is not part of an index.
the variable has a simple index. No other variables are included in the index.
the variable is part of a composite index.
the variable has a simple index and is part of a composite index.
variable informat. The value is a blank if you do not associate an informat with the variable.
number of decimals you specify when you associate the informat with the variable. The value is 0 if you do not specify decimals when you associate the informat with the variable.
informat length. If you specify a length for the informat when you associate the informat with a variable, the length you specify is the value of INFORML. If you do not specify a length for the informat when you associate the informat with a variable, the value of INFORML is the default length of the informat if you use the FMTLEN option and 0 if you do not use the FMTLEN option.
justification (0=left, 1=right).
variable label (blank if none given).
variable length.
libref used for the data library.
label for this SAS data set (blank if no label).
SAS data set that contains the variable.
library member type (DATA or VIEW).
date the data set was last modified.
variable name.
number of observations in the data set.
indicates whether the NODUPKEY option was used in a PROC SORT statement to sort the input data set.
indicates whether the NODUPREC option was used in a PROC SORT statement to sort the input data set.
physical position of the first character of the variable in the data set.
indicates whether the data set can be addressed by observation.
the first letter of the level of protection. The value for PROTECT is one or more of the following:
A |
indicates the data set is alter-protected. |
R |
indicates the data set is read-protected. |
W |
indicates the data set is write-protected. |
indicates whether the space made available when observations are deleted from a compressed data set should be reused. If the data set is not compressed, the REUSE variable has a value of NO.
the value depends on the sorting characteristics of the input data set. The following are possible values:
. (period) |
for not sorted. |
0 |
for sorted but not validated. |
1 |
for sorted and validated. |
the value depends on that variable's role in the sort. The following are possible values:
if the variable was not used to sort the input data set.
where n is an integer that denotes the position of that variable in the sort. A negative value of n indicates that the data set is sorted by the descending order of that variable.
type of the variable (1=numeric, 2=character).
special data set type (blank if no TYPE= value is specified).
variable number in the data set. Variables are numbered in the order they appear.
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 Describing a SAS Data Set and in Procedure Output.
run; 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 4 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 2 6 11 HEALTH GROUP Test Subjects STATE 2 3 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 24MAR05:10:29:38 24MAR05:13:08:53 0 2 0 0 58 148 V9 24MAR05:10:29:38 24MAR05:13:08:53 0 3 0 0 43 148 V9 24MAR05:10:29:38 24MAR05:13:08:53 0 4 0 1 16 148 V9 24MAR05:10:29:38 24MAR05:13:08:53 0 5 0 0 82 148 V9 24MAR05:10:29:38 24MAR05:13:08:53 0 6 0 0 24 148 V9 24MAR05:10:29:38 24MAR05:13:08:53 0 7 0 0 78 148 V9 24MAR05:10:29:38 24MAR05:13:08:53 0 8 0 0 28 148 V9 24MAR05:10:29:38 24MAR05:13:08:53 0 9 0 1 0 148 V9 24MAR05:10:29:38 24MAR05:13:08:53 0 10 0 0 76 148 V9 24MAR05:10:29:38 24MAR05:13:08:53 0 11 0 0 73 148 V9 24MAR05:10:29:38 24MAR05:13:08:53 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 ODS Output.
The OUT2= option in the CONTENTS statement creates an output data set that contains information about indexes and integrity constraints. Here are the variables in the output data set:
contains YES if the index is owned by the integrity constraint.
contains YES if the integrity constraint is inactive.
libref used for the data library.
SAS data set that contains the variable.
the value of MESSAGE=, if it is used, in the IC CREATE statement.
the value is blank unless an integrity constraint is violated and you specified a message.
the name of the index or integrity constraint.
contains YES if the NOMISS option is defined for the index.
the number of distinct values in the index (displayed for centiles).
the number of variables involved in the index or integrity constraint.
for a foreign key integrity constraint, contains RESTRICT or SET NULL if applicable (the ON DELETE option in the IC CREATE statement).
for a foreign key integrity constraint, contains RESTRICT or SET NULL if applicable (the ON UPDATE option in the IC CREATE statement).
the SAS statement necessary to recreate the index or integrity constraint.
for a foreign key integrity constraint, contains the name of the referenced data set.
the type. For an index, the value is "Index" while for an integrity constraint, the value is the type of integrity constraint (Not Null, Check, Primary Key, and so on).
contains YES if the UNIQUE option is defined for the index.
the percentage of the index that has been updated since the last refresh (displayed for centiles).
the percentage of the index update that triggers a refresh (displayed for centiles).
for a check integrity constraint, contains the WHERE statement.
Copyright © 2010 by SAS Institute Inc., Cary, NC, USA. All rights reserved.