DATASETS Procedure

PROC DATASETS Statement

Manages SAS files.

Syntax

PROC DATASETS <option-1 <...option-n>>;

Summary of Optional Arguments

provides Alter access to any alter-protected SAS file in the SAS library.
includes information in the log about the number of observations, number of variables, number of indexes, and data set labels.
forces either a RUN group to execute even when there are errors or forces an append operation.
restricts processing for generation data sets.
deletes SAS files.
specifies the procedure input/output library.
restricts processing to a certain type of SAS file.
see the description of DETAILS | NODETAILS.
suppresses the printing of the directory.
suppresses error processing.
provides Read, Write, or Alter access.
provides Read access.

Optional Arguments

ALTER=alter-password
provides the Alter password for any alter-protected SAS files in the SAS library.
DETAILS | NODETAILS
determines whether the following columns are written to the log:
Obs, Entries, or Indexes
gives the number of observations for SAS files of type AUDIT, DATA, and VIEW; the number of entries for type CATALOG; and the number of files of type INDEX that are associated with a data file, if any. If SAS cannot determine the number of observations in a SAS data set, the value in this column is set to missing. For example, in a very large data set, if the number of observations or deleted observations exceeds the number that can be stored in a double-precision integer, the count shows as missing. The value for type CATALOG is the total number of entries. For other types, this column is blank.
Tip:The value for files of type INDEX includes both user-defined indexes and indexes created by integrity constraints. To view index ownership and attribute information, use PROC DATASETS with the CONTENTS statement and the OUT2 option.
Vars
gives the number of variables for types AUDIT, DATA, and VIEW. If SAS cannot determine the number of variables in the SAS data set, the value in this column is set to missing. For other types, this column is blank.
Label
contains the label associated with the SAS data set. This column prints a label only for the type DATA.
The DETAILS option affects output only when a directory is specified and requires Read access to all read-protected SAS files in the SAS library. If you do not supply the Read password, the directory listing contains missing values for the columns produced by the DETAILS option.
Default:If neither DETAILS or NODETAILS is specified, the default is the system option setting. The default system option setting is NODETAILS.
Tip:If you are using the SAS windowing environment and specify the DETAILS option for a library that contains read-protected SAS files, a dialog box prompts you for each Read password that you do not specify in the PROC DATASETS statement. Therefore, you might want to assign the same Read password to all SAS files in the same SAS library.
FORCE
performs two separate actions:
  • forces a RUN group to execute even if errors are present in one or more statements in the RUN group. See RUN-Group Processing for a discussion of RUN-group processing and error handling.
  • forces all APPEND statements to concatenate two data sets even when the variables in the data sets are not exactly the same. The APPEND statement drops the extra variables and issues a warning message to the SAS log unless the NOWARN option is specified (either with the APPEND statement or PROC DATASETS). Refer to APPEND statement for more information about the FORCE option.
GENNUM=ALL | HIST | REVERT | integer
restricts processing for generation data sets. Valid values are as follows:
ALL
for subordinate CHANGE and DELETE statements, refers to the base version and all historical versions in a generation group.
HIST
for a subordinate DELETE statement, refers to all historical versions, but excludes the base version in a generation group.
REVERT | 0
for a subordinate DELETE statement, refers to the base version in a generation group and changes the most current historical version, if it exists, to the base version.
integer
for subordinate AUDIT, CHANGE, MODIFY, DELETE, and REPAIR statements, refers to a specific version in a generation group. Specifying a positive number is an absolute reference to a specific generation number that is appended to a data set name (that is, gennum=2 specifies MYDATA#002). Specifying a negative number is a relative reference to a historical version in relation to the base version, from the youngest to the oldest (that is, gennum=-1 refers to the youngest historical version).
KILL
deletes all SAS files in the SAS library that are available for processing. The MEMTYPE= option subsets the member types that the statement deletes. The following example deletes all the data files in the WORK library:
proc datasets lib=work kill memtype=data; run; quit;
CAUTION:
The KILL option deletes the SAS files immediately after you submit the statement.
If the SAS file has an ALTER= password assigned, it must be specified in order to delete the SAS file.
LIBRARY=libref
names the library that the procedure processes. This library is the procedure input/output library.
Alias:DDNAME=, DD=, LIB=
Default:WORK or USER.
Note:A SAS library that is accessed via a sequential engine (such as a tape format engine) cannot be specified as the value of the LIBRARY= option.
See:For information about the WORK and USER libraries, see One-level SAS Data Set Names in SAS Language Reference: Concepts.
MEMTYPE=(mtype(s))
restricts processing to one or more member types and restricts the listing of the data library directory to SAS files of the specified member types. For example, the following PROC DATASETS statement limits processing to SAS data sets in the default data library and limits the directory listing in the SAS log to SAS files of member type DATA:
proc datasets memtype=data;
Alias:MTYPE=, MT=
Default:ALL
NODETAILS
See DETAILS | NODETAILS.
NOLIST
suppresses the printing of the directory of the SAS files in the SAS log.
Note:If you specify the ODS RTF destination, 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.
NOWARN
suppresses the error processing that occurs when a SAS file that is specified in a SAVE, CHANGE, EXCHANGE, REPAIR, DELETE, or COPY statement or listed as the first SAS file in an AGE statement, is not in the procedure input library. When an error occurs and the NOWARN option is in effect, PROC DATASETS continues processing that RUN group. If NOWARN is not in effect, PROC DATASETS stops processing that RUN group and issues a warning for all operations except DELETE, for which it does not stop processing.
PW= password
provides the password for any protected SAS files in the SAS library. PW= can act as an alias for READ=, WRITE=, or ALTER=.
READ=read-password
provides the Read password for any read-protected SAS files in the SAS library.