BookmarkSubscribeRSS Feed
thanikondharish
Calcite | Level 5
I have libray . library name is Main. Main library has some many datasets .In those datasets some datasets contain only variables there is no data and some datasets has data.
My question is how to know which datasets have data and which datasets haven't data at time
3 REPLIES 3
rajeshalwayswel
Pyrite | Level 9

%let dsid=%sysfunc(open(sashelp.class));
%let nobs=%sysfunc(attrn(&dsid,nlobs));
%let dsid=%sysfunc(close(&dsid));

%put nobs= &nobs ;

Kurt_Bremser
Super User

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;
s_lassen
Meteorite | Level 14

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;

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 754 views
  • 0 likes
  • 4 in conversation