Clean-Up: Delete datasets in the work library:
It is better always to clean-up/empty the work directory before we run the next set of SAS code. This is VERY helpful in situations where the “working” files created tend to use up a large amount of memory, once the logic of the program has been checked, KILLing the working files will result in a more efficient program. Another important reason to issue the above statement at the end of a program is when programs are run in batch, this will clean up the working library to be sure any “old” files are not left around to be erroneously used1.
PROC DATASETS procedure offers an elegant solution to do just.
Remember that there is no need of knowing any dataset names when we are emptying the work directory.
Here is the simple syntax:
proc datasets lib=work kill nolist memtype=data;
quit;
We have specified lib=work, because we are cleaning up the work directory.
KILL option removes all the datasets that are happened to be in the work directory.
NOLIST option tells SAS, printing the details isn’t required.
Since our main objective here to remove the datasets and not the catalogs, we need to specify MEMTYPE=DATA.
To remove datasets and catalogs…use. MEMTYPE=ALL.
What if we need to delete only some datasets and not all….
Proc DATASETS procedure has a solution for it also….datasets..
The following code only deletes 2 datasets, named AE and DEMO.
proc datasets lib=work nolist;
delete AE DEMO;
quit;
run;
CAUTION:
The KILL option deletes the SAS files immediately after you submit the statement.
Source: sugi28 proceedings..page 190-28.pdf
PROC DATASETS procedure offers an elegant solution to do just.
Remember that there is no need of knowing any dataset names when we are emptying the work directory.
Here is the simple syntax:
proc datasets lib=work kill nolist memtype=data;
quit;
We have specified lib=work, because we are cleaning up the work directory.
KILL option removes all the datasets that are happened to be in the work directory.
NOLIST option tells SAS, printing the details isn’t required.
Since our main objective here to remove the datasets and not the catalogs, we need to specify MEMTYPE=DATA.
To remove datasets and catalogs…use. MEMTYPE=ALL.
What if we need to delete only some datasets and not all….
Proc DATASETS procedure has a solution for it also….datasets..
The following code only deletes 2 datasets, named AE and DEMO.
proc datasets lib=work nolist;
delete AE DEMO;
quit;
run;
CAUTION:
The KILL option deletes the SAS files immediately after you submit the statement.
Source: sugi28 proceedings..page 190-28.pdf
I keep getting errors caused by windows not keeping up with SAS:
ReplyDeleteERROR: User does not have appropriate authorization level for library WORK.
I get this error randomly. Some days, no problem, other time upwards 50% of data set access.
I do have all rights to the temp folders on my c drive but the affected files are still locked (.lck) by the time a later data step (or proc sort) wants to overright or up date the work data set.
I'll try your code and see what happens.