PROC DATASETS - KILL Statement
Following is the code, for deleteing all the datasets from the library.
SAS Code: PROC DATASETS - KILL Option
libname temp 'D:\SAS_Datasets\';
Setting up the Background
SAS Code:
libname temp 'D:\SAS_Datasets\';
data temp.c;
amt = 5600;
run;
data temp.d;
amt = 5600;
run;
<< Back to the PROC DATASETS Page.
If someone wants to delete all the datasets from a library; might be for house keeping purpose then you have a quick way of doing it using PROC DATASETS - KILL option
Remember, this will only delete only datasets stored in that library, all other kind of members like Macros, catalogues, formats etc. will remain untouched.
SYNTAX:
proc datasets lib="libname" KILL;
quit;
EXAMPLE:
Before moving to the actual demonstrations we will set up the environment.
Following code declares one library and creates some SAS datasets inside; just for demo purpose.
/* Just to see the contents of library before deleting */
proc datasets lib=temp;
quit;
/* This step will actually delete the datasets from the library */
proc datasets lib=temp kill;
quit;
/* Displays the contents after deleting */
proc datasets lib=temp;
quit;
Following is the output of the code above. (Note, this is just a part of the actual output).
OUTPUT: PROC DATASETS - KILL Option
The list of datasets seen above are the contents of the library 'TEMP' before killing the datasets as a result of first PROC DATASETS procedure executed.
After executing the code for deleting all the datasets if you again try to view the contents of the library (using the third PROC DATASETS procedure in the SAS CODE above) then we will get the warning in the log as there are no datasets in the library.
A part of Log Waring showing the warning statement is given below.
SAS LOG: PROC DATASETS - KILL Option
100 proc datasets lib=temp;
WARNING: No matching members in directory.
101 contents;