Hello, I am having an issue with something in SAS (version 9.4) and could use some expertise! Basically my macro currently looks like this:
proc sql;
select count(*) into: thirtyfive_counts
from history_upi, dummy_upi_clean, dummy_upi_76, history_upi_76;
quit;
%macro yyy(when);
%if &when ne 0 %then %do;
%include 'G:\Groups\HHR\new 35 file.sas';
%end;
%mend;
%yyy(&thirtyfive_counts);
Ultimately, I want this program(in the include statement) to be run if there are any records in any of those 4 datasets (listed in the from statement). The issue I am having is if one of those datasets is empty (which will sometimes be the case) it is giving me an error and not running the program. However, if I only list the datasets where this is a record, it will work fine. I would like it to run if there is an observation in any of the four datasets. Is this possible?
Thanks!
%let thirtyfive_counts=0;
proc sql no print;
select sum(nobs) into: thirtyfive_counts
from dictionary.tables
where libname = 'WORK' and lowercase(memname) in
("history_upi","dummy_upi_clean","dummy_upi_76","history_upi_76");
quit;
is the correct way to determine this. If none of these datasets exists, you still get a zero.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.