Copying, Moving, and Deleting SAS Data Sets |
Selecting Data Sets to Copy |
To copy only a few data sets from a large SAS data library, use the SELECT statement with the COPY statement. After the keyword SELECT, list the data set name(s) with a blank space between the names, or use an abbreviated member list (such as YRDATA1-YRDATA5) if applicable.
For example, the following statements copy the data set HURRICANE from the library USCLIM to the library STORM. The input procedure library is PRECIP, so the COPY statement includes the IN= option in order to specify the USCLIM input library.
copy in=usclim out=storm; select hurricane; run;
The following SAS log shows that only the data set HURRICANE was copied to the library STORM:
Copying the Data Set HURRICANE to the Library STORM
76 copy in=usclim out=storm; 77 select hurricane; 78 run; NOTE: Copying USCLIM.HURRICANE to STORM.HURRICANE (memtype=DATA). NOTE: There were 5 observations read from the data set USCLIM.HURRICANE. NOTE: The data set STORM.HURRICANE has 5 observations and 5 variables.
Excluding Data Sets from Copying |
To copy an entire library except for a few data sets, use the EXCLUDE statement with the COPY statement. After the keyword EXCLUDE, simply list the data set name(s) that you want to exclude with a blank space between the names, or use an abbreviated member list (such as YRDATA1-YRDATA5) if applicable.
The following statements copy the files in the library PRECIP to USCLIM except for the data set SNOW. The procedure input library is PRECIP, so the IN= option is not needed.
copy out=usclim; exclude snow; run;
The following SAS log shows that the data set RAIN was copied to USCLIM and that the data set SNOW remains only in the library PRECIP:
Excluding the Data Set SNOW from Copying to the Library USCLIM
96 copy out=usclim; 97 exclude snow; 98 run; NOTE: Copying PRECIP.RAIN to USCLIM.RAIN (memtype=DATA). NOTE: There were 5 observations read from the data set PRECIP.RAIN. NOTE: The data set USCLIM.RAIN has 5 observations and 4 variables.
Copyright © 2012 by SAS Institute Inc., Cary, NC, USA. All rights reserved.