The 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;
148 proc datasets library=health memtype=data details; Directory Libref HEALTH Engine V9 Physical Name SAS library 2 File Name SAS library 2 Member Obs, Entries File # Name Type or Indexes Vars Label Size Last Modified 1 ALL DATA 23 17 13312 12Sep07:13:57:48 2 BODYFAT DATA 1 2 5120 12Sep07:13:57:48 3 CONFOUND DATA 8 4 5120 12Sep07:13:57:48 4 CORONARY DATA 39 4 5120 12Sep07:13:57:48 5 DRUG1 DATA 6 2 JAN2005 DATA 5120 12Sep07:13:57:49 6 DRUG2 DATA 13 2 MAY2005 DATA 5120 12Sep07:13:57:49 7 DRUG3 DATA 11 2 JUL2005 DATA 5120 12Sep07:13:57:49 8 DRUG4 DATA 7 2 JAN2002 DATA 5120 12Sep07:13:57:49 9 DRUG5 DATA 1 2 JUL2002 DATA 5120 12Sep07:13:57:49 10 GROUP DATA 148 11 25600 12Sep07:13:57:50 11 GRPOUT DATA 11 40 17408 24Mar05:15:33:31 12 MLSCL DATA 32 4 Multiple Sclerosis Data 5120 12Sep07:13:57:50 13 NAMES DATA 7 4 5120 12Sep07:13:57:50 14 OXYGEN DATA 31 7 9216 12Sep07:13:57:50 15 PERSONL DATA 148 11 25600 12Sep07:13:57:51 16 PHARM DATA 6 3 Sugar Study 5120 12Sep07:13:57:51 17 POINTS DATA 6 6 5120 12Sep07:13:57:51 18 PRENAT DATA 149 6 17408 12Sep07:13:57:51 19 RESULTS DATA 10 5 5120 12Sep07:13:57:52 20 SLEEP DATA 108 6 9216 12Sep07:13:57:52 21 SYNDROME DATA 46 8 9216 12Sep07:13:57:52 22 TENSION DATA 4 3 5120 12Sep07:13:57:52 23 TEST2 DATA 15 5 5120 12Sep07:13:57:52 24 TRAIN DATA 7 2 5120 12Sep07:13:57:53 25 VISION DATA 16 3 5120 12Sep07:13:57:53 26 WEIGHT DATA 83 13 California Results 13312 12Sep07:13:57:53 27 WGHT DATA 83 13 13312 12Sep07:13:57:53 6 ! delete syndrome; change 7 prenat=infant; run; NOTE: Deleting HEALTH.SYNDROME (memtype=DATA). NOTE: Changing the name HEALTH.PRENAT to HEALTH.INFANT (memtype=DATA). 7 ! quit; NOTE: PROCEDURE DATASETS used (Total process time): real time 17.10 seconds cpu time 0.15 seconds
Notes |
Although the DATASETS procedure can perform some operations on catalogs, generally the CATALOG procedure is the best utility to use for managing catalogs. For documentation of PROC CATALOG, see Overview: CATALOG Procedure.
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.
Copyright © 2010 by SAS Institute Inc., Cary, NC, USA. All rights reserved.