O'Reilly logo

Step-by-Step Programming with Base SAS 9.4, Second Edition, 2nd Edition by SAS Institute

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

run;
quit;
Specifying Data Sets to Save
To delete all data sets but a few, you can use the SAVE statement to list the names of the
data sets that you want to keep. List the data set names with a blank space between the
names, or use an abbreviated member list (such as YRDATA1-YRDATA5) if applicable.
The following statements delete all the data sets except TEMPCHNG from the library
USCLIM:
proc datasets library=usclim;
save tempchng;
run;
The following output shows the SAS log from the Save operation. SAS sends
messages to the log, verifying that it has kept the data sets that you specified in the
SAVE statement and deleted all other members of the library.
Log 39.10 Deleting All Members of the Library USCLIM except the Data Set TEMPCHNG
171 proc datasets library=usclim;
172 save tempchng;
173 run;
NOTE: Saving USCLIM.TEMPCHNG (memtype=DATA).
NOTE: Deleting USCLIM.BASETEMP (memtype=CATALOG).
NOTE: Deleting USCLIM.HIGHTEMP (memtype=DATA).
NOTE: Deleting USCLIM.LOWTEMP (memtype=DATA).
NOTE: Deleting USCLIM.REPORT (memtype=CATALOG).
NOTE: Deleting USCLIM.USHIGH (memtype=DATA).
NOTE: Deleting USCLIM.USLOW (memtype=DATA).
Deleting All Files in a SAS Library
To delete all files in a SAS library at one time, use the KILL option in the PROC
DATASETS statement.
CAUTION:
The KILL option deletes all members of the library immediately after the
statement is submitted. You are not asked to verify the Delete operation, so make
sure that you intend to delete the files before submitting the program.
For example, the following program deletes all data sets in the library WEATHER and
stops the DATASETS procedure:
proc datasets library=weather kill;
run;
quit;
Deleting All Files in a SAS Library 735

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required