just to introduce another idea:
Although the datepart() function has achieved what was called for, it isn't really neccessary.
But that's OK here, because for such small data volumes, performance is not an issue.
However, where data base volumes are significant, for testing a datetime value against a date constant, just extend the constant with 0 time information. Rather than applying a datepart() function on every row, extending the constant happens only once. For example[pre]proc sql ;
create table vtable as select * from sashelp.vtable
where libname = 'WANTED'
& modate lt "%sysfunc( sum( '&sysdate'd, -3), date9):0:0:0"dt
proc sql noprint nowarn;
select catx('.',libname,memname) into :dropmems separated by ','
where libname =%upcase("&CleanupLib") and memtype="DATA"
and today()-datepart(coalesce(modate,crdate)) > 2;
%if &dropmems ne %then %do;
%put ************ Tables will be dropped ******;
drop table &dropmems;
%put ************ No tables to be dropped ******;
Message was edited by: Patrick