Hi FUN
Following this thread I suddenly remembered that I have something in my box which needed only a bit of change to cover your requirements.
Have a look at the code below.
I changed your 'modate' part in the clause to 'coalesce(modate,crdate)' as I saw in the dictionary table that there are entries with a blank modate.
HTH
Patrick
%macro CleanUpLib(CleanupLib=);
options mprint;
%local dropmems;
proc sql noprint nowarn;
select catx('.',libname,memname) into :dropmems separated by ','
from dictionary.tables
where libname =%upcase("&CleanupLib") and memtype="DATA"
and today()-datepart(coalesce(modate,crdate)) > 2;
%if &dropmems ne %then %do;
%put ************ Tables will be dropped ******;
%put Dropmems=&dropmems;
drop table &dropmems;
%end;
%else %do;
%put ************ No tables to be dropped ******;
%end;
quit;
run;
%mend;
%CleanUpLib(CleanupLib=MyLib)
Message was edited by: Patrick
... View more