%macro populate_set_statement(current_date); %let current_date_num = %sysfunc(inputn(¤t_date., yymmdd10.)); %let current_date_minus_363 = %eval(¤t_date_num - 363); %let current_date_minus_347 = %eval(¤t_date_num - 347); data all; set %do i = %sysfunc(inputn(20250317, yymmdd10.)) %to ¤t_date_num; %if %sysfunc(exist(both_%sysfunc(putn(&i., mmddyy6.)))) %then both_%sysfunc(putn(&i., mmddyy6.)); %end; %do j = ¤t_date_minus_363 %to ¤t_date_minus_347; %if %sysfunc(exist(all22_%sysfunc(putn(&j., mmddyy6.)))) %then all22_%sysfunc(putn(&j., mmddyy6.)); %end; ; run; %mend populate_set_statement; %populate_set_statement(%sysfunc(today(), yymmdd10.)); Using SAS 9.4 (TS1M7). I have this part of a program that auto populates a dataset "all" based on dates. There is a chance in the future that some of the datasets used to create the datasets in the set statement above will be empty causing All not to be created. Can someone give me a work around so that if a dataset is empty it is removed from the set statement? Thanks.
... View more