DATASETS Procedure

Overview: DATASETS Procedure

What Does the DATASETS Procedure Do?

The DATASETS procedure is a utility procedure that manages your SAS files. With PROC DATASETS, you can do the following:
  • copy SAS files from one SAS library to another
  • rename SAS files
  • repair SAS files
  • delete SAS files
  • list the SAS files that are contained in a SAS library
  • list the attributes of a SAS data set, such as:
    • the date when the data was last modified
    • whether the data is compressed
    • whether the data is indexed
  • manipulate passwords on SAS files
  • append SAS data sets
  • modify attributes of SAS data sets and variables within the data sets
  • create and delete indexes on SAS data sets
  • create and manage audit files for SAS data sets
  • create and delete integrity constraints on SAS data sets

Sample PROC DATASETS Output

The following DATASETS procedure includes the following:
  • copies all data sets from the CONTROL library to the HEALTH library
  • lists the contents of the HEALTH library
  • deletes the SYNDROME data set from the HEALTH library
  • changes the name of the PRENAT data set to INFANT
The SAS log is shown in the following output.
LIBNAME control 'SAS-library-1';
LIBNAME health 'SAS-library-2';
proc datasets memtype=data;
   copy in=control out=health;
run;

proc datasets library=health memtype=data details;
   delete syndrome;
   change prenat=infant;
run;
quit;
Log from PROC DATASETS

744  proc datasets library=health memtype=data details;
                                   Directory

Libref         HEALTH
Engine         V9
Physical Name  c:\Documents and Settings\myfile\My Documents\procdatasets\health
Filename       c:\Documents and Settings\myfile\My Documents\procdatasets\health


              Member  Obs, Entries                                   File
 #  Name      Type     or Indexes   Vars  Label                      Size  Last Modified

 1  ALL       DATA         23        17                             13312  12Sep07:10:57:50
 2  BODYFAT   DATA         83        13   California Results        13312  12Sep07:10:57:54
 3  CONFOUND  DATA          8         4                              5120  12Sep07:10:57:50
 4  CORONARY  DATA         39         4                              5120  12Sep07:10:57:50
 5  DRUG1     DATA          6         2   JAN2005 DATA               5120  12Sep07:10:57:50
 6  DRUG2     DATA         13         2   MAY2005 DATA               5120  12Sep07:10:57:50
 7  DRUG3     DATA         11         2   JUL2005 DATA               5120  12Sep07:10:57:50
 8  DRUG4     DATA          7         2   JAN2002 DATA               5120  12Sep07:10:57:50
 9  DRUG5     DATA          1         2   JUL2002 DATA               5120  12Sep07:10:57:50
10  GROUP     DATA        148        11   Test Subjects             33792  12Sep07:13:01:16
    GROUP     INDEX         1                                        9216  12Sep07:13:01:16
11  GRPOUT    DATA         11        40                             17408  13Dec10:11:40:24
12  GRPOUT1   DATA         11        40                             17408  13Dec10:10:28:32
13  INFANT    DATA        149         6                             17408  12Sep07:10:57:52
14  MLSCL     DATA         32         4   Multiple Sclerosis Data    5120  12Sep07:10:57:52
15  NAMES     DATA          7         4                              5120  12Sep07:10:57:52
16  OXYGEN    DATA         31         7                             17408  12Sep07:13:01:16
17  PERSONL   DATA        148        11                             25600  12Sep07:10:57:52
18  PHARM     DATA          6         3   Sugar Study                5120  12Sep07:10:57:52
19  POINTS    DATA          6         6                              5120  12Sep07:10:57:52
20  RESULTS   DATA         10         5                              5120  12Sep07:10:57:54
21  SLEEP     DATA        108         6                              9216  12Sep07:10:57:54
22  TEST2     DATA         15         5                              5120  12Sep07:10:57:54
23  TRAIN     DATA          7         2                              5120  12Sep07:10:57:54
24  VISION    DATA         16         3                              5120  12Sep07:10:57:54
25  WEIGHT    DATA          1         2                              5120  12Sep07:10:57:50
26  WGHT      DATA         83        13                             13312  12Sep07:10:57:54
745     delete syndrome;
746     change prenat=infant;
747  run;
ERROR: The file HEALTH.PRENAT (memtype=DATA) was not found, but appears on a CHANGE statement.
748  quit;
749
750  proc datasets memtype=data;

Notes

  • Although the DATASETS procedure can perform some operations on catalogs, generally the CATALOG procedure is the best utility to use for managing catalogs.
  • The term member often appears as a synonym for SAS file. If you are unfamiliar with SAS files and SAS libraries, refer to SAS Files Concepts in SAS Language Reference: Concepts.
  • PROC DATASETS cannot work with sequential data libraries.
  • You cannot change the length of a variable using the LENGTH statement or the LENGTH= option on an ATTRIB statement.
  • There can be a discrepancy between the modified date in PROC DATASETS, PROC CONTENTS, and other components of SAS, such as SAS Explorer. The two modified dates and times are distinctly different:
    • Operating-environment modified date and time is reported by the SAS Explorer and the PROC DATASETS LIST option.
    • The modified date and time reported by the CONTENTS statement is the date and time that the data within the data set was actually modified.
  • If you have a library containing a large number of members, the DATASETS procedure might show an increase in process time. You might want to reorganize your library into smaller libraries for better performance.