Discover More Tips and Techniques on This Blog

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

Disclosure:

In the spirit of transparency and innovation, I want to share that some of the content on this blog is generated with the assistance of ChatGPT, an AI language model developed by OpenAI. While I use this tool to help brainstorm ideas and draft content, every post is carefully reviewed, edited, and personalized by me to ensure it aligns with my voice, values, and the needs of my readers. My goal is to provide you with accurate, valuable, and engaging content, and I believe that using AI as a creative aid helps achieve that. If you have any questions or feedback about this approach, feel free to reach out. Your trust and satisfaction are my top priorities.