Previous Page | Next Page

The DATASETS Procedure

CONTENTS Statement


Describes the contents of one or more SAS data sets and prints the directory of the SAS library.
Restriction: You cannot use the WHERE option to affect the output because PROC CONTENTS does not process any observations.
Tip: You can use data set options with the DATA=, OUT=, and OUT2= options. You can use any global statements as well. See Global Statements.
Featured in: Describing a SAS Data Set

CONTENTS <option-1 <...option-n>>;

Task Option
Specify the input data set DATA=
Specify the name for an output data set OUT=
Specify the name of an output data set to contain information about indexes and integrity constraints OUT2=
Include information in the output about the number of observations, number of variables, number of indexes, and data set labels DETAILS|NODETAILS
Print a list of the SAS files in the SAS library DIRECTORY
Print the length of a variable's informat or format FMTLEN
Restrict processing to one or more types of SAS files MEMTYPE=
Suppress the printing of individual files NODS
Suppress the printing of the output NOPRINT
Print a list of the variables by their position in the data set. By default, the CONTENTS statement lists the variables alphabetically. VARNUM
Print a list of variables in alphabetical and numeric order beginning with uppercase and then lowercase names ORDER=COLLATE
Print a list of variables in alphabetical and numeric order even if they include mixed-case names ORDER=CASECOLLATE
Print a list of variables in alphabetical order, ignoring the case of the letters ORDER=IGNORECASE
Print a list of variables in the order of their logical position in the data set ORDER=VARNUM
Print abbreviated output SHORT
Print centiles information for indexed variables CENTILES


Options

CENTILES

prints centiles information for indexed variables.

The following additional fields are printed in the default report of PROC CONTENTS when the CENTILES option is selected and an index exists on the data set. Note that the additional fields depend on whether the index is simple or complex.

#

number of the index on the data set.

Index

name of the index.

Update Centiles

percentage of the data values that must be changed before the CENTILES for the indexed variables are automatically updated.

Current Update Percentage

percentage of index updated since CENTILES were refreshed.

# of Unique Values

number of unique indexed values.

Variables

names of the variables used to make up the index. Centile information is listed below the variables.

DATA=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. The default for libref is the libref of the procedure input library. For example, to obtain the contents of the SAS data set HTWT from the procedure input library, use the following CONTENTS statement:

contents data=HtWt;
To obtain the contents of a specific version from a generation group, use the GENNUM= data set option as shown in the following CONTENTS statement:
contents data=HtWt(gennum=3);
<libref.>_ALL_

gives you information about all SAS data sets that have the type or types specified by the MEMTYPE= option. libref refers to the SAS library. The default for libref is the libref of the procedure input library.

  • If you are using the _ALL_ keyword, you need read access to all read-protected SAS data sets in the SAS library.

  • DATA=_ALL_ automatically prints a listing of the SAS files that are contained in the SAS library. Note that for SAS views, all librefs that are associated with the views must be assigned in the current session in order for them to be processed for the listing.

Default: most recently created data set in your job or session, from any SAS library.
Tip: If you specify a read-protected data set in the DATA= option but do not give the read password, by default the procedure looks in the PROC DATASETS statement for the read password. However, if you do not specify the DATA= option and the default data set (last one created in the session) is read protected, the procedure does not look in the PROC DATASETS statement for the read password.
Featured in: Describing a SAS Data Set
DETAILS|NODETAILS

DETAILS includes these additional columns of information in the output, but only if DIRECTORY is also specified.

Default: If neither DETAILS nor NODETAILS is specified, the defaults are as follows: for the CONTENTS procedure, the default is the system option setting, which is NODETAILS; for the CONTENTS statement, the default is whatever is specified in the PROC DATASETS statement, which also defaults to the system option setting.
See also: description of the additional columns in "Options" in PROC DATASETS Statement
DIRECTORY

prints a list of all SAS files in the specified SAS library. If DETAILS is also specified, using DIRECTORY causes the additional columns described in DETAILS|NODETAILS to be printed.

FMTLEN

prints the length of the informat or format. If you do not specify a length for the informat or format when you associate it with a variable, the length does not appear in the output of the CONTENTS statement unless you use the FMTLEN option. The length also appears in the FORMATL or INFORML variable in the output data set.

MEMTYPE=(mtype-1 <...mtype-n>)

restricts processing to one or more member types. The CONTENTS statement produces output only for member types DATA, VIEW, and ALL, which includes DATA and VIEW.

MEMTYPE= in the CONTENTS statement differs from MEMTYPE= in most of the other statements in the DATASETS procedure in the following ways:

  • A slash does not precede the option.

  • You cannot enclose the MEMTYPE= option in parentheses to limit its effect to only the SAS file immediately preceding it.

MEMTYPE= results in a directory of the library in which the DATA= member is located. However, MEMTYPE= does not limit the types of members whose contents are displayed unless the _ALL_ keyword is used in the DATA= option. For example, the following statements produce the contents of only the SAS data sets with the member type DATA:

proc datasets memtype=data;
   contents data=_all_;
run;
Aliases: MT=, MTYPE=
Default: DATA
NODS

suppresses printing the contents of individual files when you specify _ALL_ in the DATA= option. The CONTENTS statement prints only the SAS library directory. You cannot use the NODS option when you specify only one SAS data set in the DATA= option.

NODETAILS

See the description of DETAILS|NODETAILS.

NOPRINT

suppresses printing the output of the CONTENTS statement.

ORDER= COLLATE | CASECOLLATE | IGNORECASE | VARNUM
COLLATE

prints a list of variables in alphabetical order beginning with uppercase and then lowercase names.

CASECOLLATE

prints a list of variables in alphabetical order even if they include mixed-case names and numerics.

IGNORECASE

prints a list of variables in alphabetical order ignoring the case of the letters.

VARNUM

is the same as the VARNUM option. See VARNUM.

Note:   The ORDER= option does not affect the order of the OUT= and OUT2= data sets.  [cautionend]

See Using the ORDER= Option with the CONTENTS Statement to compare the default and the four options for ORDER=.

OUT=SAS-data-set

names an output SAS data set.

Tip: OUT= does not suppress the printed output from the statement. If you want to suppress the printed output, you must use the NOPRINT option.
See: The OUT= Data Set for a description of the variables in the OUT= data set.
See also: ODS Output for an example of how to get the CONTENTS output into an ODS data set for processing.
OUT2=SAS-data-set

names the output data set to contain information about indexes and integrity constraints.

Tip: If UPDATECENTILES was not specified in the index definition, then the default value of 5 is used in the RECREATE variable of the OUT2 data set.
Tip: OUT2= does not suppress the printed output from the statement. To suppress the printed output, use the NOPRINT option.
See also: The OUT2= Data Set for a description of the variables in the OUT2= data set.
SHORT

prints only the list of variable names, the index information, and the sort information for the SAS data set.

Restriction: If the list of variables is more than 32,767 characters, the list is truncated and a WARNING is written to the SAS log. To get a complete list of the variables, request an alphabetical listing of the variables.
VARNUM

prints a list of the variable names in the order of their logical position in the data set. By default, the CONTENTS statement lists the variables alphabetically. The physical position of the variable in the data set is engine-dependent.


Details

The CONTENTS statement prints an alphabetical listing of the variables by default, except for variables in the form of a numbered range list. Numbered range lists, such as x1-x100, are printed in incrementing order, that is, x1-x100. For more information, see Alphabetic List of Variables and Attributes.

Note:   If a label is changed after a view is created from a data set with variable labels, the CONTENTS or DATASETS procedure output shows the original labels. The view must be recompiled in order for the CONTENTS or DATASETS procedure output to reflect the new variable labels.  [cautionend]


Using the CONTENTS Procedure instead of the CONTENTS Statement

The only difference between the CONTENTS procedure and the CONTENTS statement in PROC DATASETS is the default for libref in the DATA= option. For PROC CONTENTS, the default is WORK. For the CONTENTS statement, the default is the libref of the procedure input library.

Previous Page | Next Page | Top of Page