You can query metadata to determine the number of observations in a table. You might want to watch out for deleted observations. select nobs-delobs into :nobs from dictionary.tables where libname='WORK' and memname='ONE' ; If you are creating a macro then you can use a %IF to generate the code. %if &nobs %then %do; drop table work.one ; %end; If you are not then you could generate the code into a macro variable. %let drop=; select 'drop table ' || catx('.',libname,memname) into :drop separated by ';' from dictionary.tables where nobs-delobs=0 and libname='WORK' and memname in ('ONE','TWO') ; &drop;
... View more