Dec 1, 2011

A SAS Macro to Clean up the WORK directory…

Here is a macro to quickly cleanup the work directory programmatically…
It uses Proc Datasets with KILL option to delete the datasets in the library…
%macro CleanupWORK(membertype);
 
/***
ACCESS - access descriptor files (created by SAS/ACCESS software)
ALL - all member types
CATALOG- SAS catalogs
DATA - SAS data files
FDB - financial database
MDDB - multidimensional database
PROGRAM - stored compiled SAS programs
VIEW - SAS views
****/
 
%let validvals=ACCESS ALL CATALOG DATA FDB MDDB PROGRAM VIEW;
%if %index(&validvals,%upcase(&membertype)) gt 0 %then
  %do;
       proc datasets lib=WORK kill nolist memtype=%upcase(&membertype);
       quit;
   %end;
%mend;
 
%CleanupWORK(data);
The valid values for the parameter memtype are ACCESS ALL CATALOG DATA FDB MDDB PROGRAM VIEW only…