SAS Programming Professionals,
Did you know that you can delete all SAS files in a given SAS data library _EXCEPT_ those that you specifically list in the SAVE statement using PROC DATASETS?
Think of PROC DATASETS’ SAVE statement as a kind of KEEP statement for SAS files instead of for SAS variables. Consider this example:
proc datasets library=raithlib;
save FaveCDList FaveMovielist;
That program deletes the dozen or so SAS data sets, catalogs, etc. in my RAITHLIB SAS data library, leaving my two favorite SAS data sets FaveCDList and FaveMovieList behind.
If I had a catalog with the same name as one of the two aforementioned SAS data sets, I would simply include a “/memtype=data” to the end of the SAVE statement, above, and that catalog would be history, but my SAS data sets wouldn’t be!
Best of luck in all your SAS endeavors!
(aka Michael A. Raithel)
Excerpt from the book: Did You Know That? Essential Hacks for Clever SAS Programmers
I plan to post each and every one of the hacks in the book to social media on a weekly basis. Please pass them along to colleagues who you know would benefit.