Hi Again, Glad you got it working. Just to correct myself, realized on the drive home that I had forgotten to check for existence of the datasets at the end of each loop, after the sleep. Below is what I had meant to suggest. Basically instead of using the SQL step to build a macro variable that will resolve to code (your ANDed list of FileExist checks), the SQL step here returns a 1 if all datasets exist, 0 if any does not exist. So it's an alternate approach that avoids the macro quoting headaches. It probably runs slower than your solution (cuz the SQL step should take longer than the %EVAL of your ANDed list), but of course speed doesn't matter when you are just waiting for something to arrive. I used exist instead of fileexist as a convenience, since they are SAS dataasets. data sasdatasets;
input datasetname $41.;
cards;
junk.a
junk.b
;
run;
libname junk "d:\junk";
%macro dosomething(dummy);
%local AllPresent i;
%*Check to see if all datasets (junk.a and junk.b) exist;
%*If all exist, min(exist(datasetname)) is 1;
%*If any does not exist, min(exist(datasetname)) is 0;
proc sql noprint;
select min(exist(datasetname)) into :AllPresent
from sasdatasets;
quit;
%let i=1;
%*if any dataset doesnt exist, sleep and then check again;
%*Will sleep a maximum of 10 times and then give up;
%do %while (&allPresent=0 and &i le 10);
%put Iter#&i: Missing at least one dataset, sleep and try again.;
%let dummy=%sysfunc(sleep(5));
%*Check to see if they all exist now;
proc sql noprint;
select min(exist(datasetname)) into :AllPresent
from sasdatasets;
quit;
%let i=%eval(&i+1);
%end;
%if &allPresent=1 %then %do;
%put All datasets exist! Continue processing...; %* Main code /macro call here;
%end;
%else %if &allPresent=0 %then %do;
%put Giving up! Still missing at least one dataset.;
%end;
%mend dosomething;
%dosomething()
... View more