BookmarkSubscribeRSS Feed
SachinRuk
Calcite | Level 5
Hi All,

The way I've setup my program I extract subsets of data (as tables) from a large dataset. Sometimes these tables are completely empty. Its become a problem since I output these tables onto a pdf and I can sometimes have a number of empty tables.

My question is, is there a way to recognise that the entire table is empty so I could skip outputing this table and go to the next?

Thanks,
Sachin
4 REPLIES 4
ArtC
Rhodochrosite | Level 12
Do you need to know if a table currently has 0 obs? 0 variables? or do you need to know that a given logical expression will produce no observations for a given data set?
SachinRuk
Calcite | Level 5
well its more that all the values are 'missing'. So to me its zero observations but thats not how SAS perceives it.

Mind you that proc gplot doesnt attempt to give me an empty graph, simply doesnt plot altogether (which is what I want).

Thanks,
Sachin Message was edited by: SachinRuk
monei011
Calcite | Level 5
there is a macro in the SAS Autocall library called obsnvars which returns the number of observations and number of variables as values of macro variables that you can then test and take action based on the values. snippet from some code where it is in use here

%obsnvars(CST.&&tablename&i);
%if &nobs GT 0
%then %do;
proc sql noprint;
create table max_date as
select
"&&tablename&i" length=50 as table_name
,max(extracteddate) as max_extracteddate
from CST.&&tablename&i
;
quit;
data all_table_dates;
set all_table_dates
max_date
;
run;
%end;
%end;
Peter_C
Rhodochrosite | Level 12
SachinRuk

While creating your subsets you might be able to collect what you seek more easily than after.
Are you using SQL or a data step or just a where clause?
Optimal solution depends on context.

HTH
peterC

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1283 views
  • 0 likes
  • 4 in conversation