%let dsid=%sysfunc(open(sashelp.class));
%let nobs=%sysfunc(attrn(&dsid,nlobs));
%let dsid=%sysfunc(close(&dsid));
%put nobs= &nobs ;
Query the relevant dictionary table for this:
proc sql;
create table empties as
select memname from dictionary.tables
where libname = 'MAIN' and nobs = 0;
quit;
DICTIONARY.TABLES is good for that:
proc sql;
select memname,nlobs from dictionary.tables
where libname='MAIN';
quit;I used NLOBS rather than NOBS, because NOBS includes deleted observations.
You can use a create table clause to put the stuff in a dataset, or you can put the table names that you want in a macro variable, e.g.:
proc sql noprint;
select memname into :notempty separated by ' '
from dictionary.tables where libname='MAIN' and NLOBS>0;
quit;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.