<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Check multiple files existence in a %DO %UNTIL macro... in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Check-multiple-files-existence-in-a-DO-UNTIL-macro/m-p/84976#M18273</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a table with a single column (sas_datasets) that has the names of files as its values, i.e.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;sas_datasets&lt;/P&gt;&lt;P&gt;-------------------------------------&lt;/P&gt;&lt;P&gt;/work/users/file1.sas7bdat&lt;/P&gt;&lt;P&gt;/work/users/file2.sas7bdat&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I use the following&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/* Note that I inserted the asterisk (*) after the percent sign (%) below to prevent it from evaluating to 0, instead I need it as text */&lt;/P&gt;&lt;P&gt;proc sql noprint; &lt;/P&gt;&lt;P&gt;select cats('%*sysfunc(fileexist(','"',sas_datasets,'"))')&lt;/P&gt;&lt;P&gt;into :untils &lt;/P&gt;&lt;P&gt;separated by ' AND ' &lt;/P&gt;&lt;P&gt;from sas_datasets&lt;/P&gt;&lt;P&gt;;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/* Here I remove the asterisk */&lt;/P&gt;&lt;P&gt;%put NOTE: %qsysfunc(compress(&amp;amp;untils,*));&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;resolves to&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%sysfunc(fileexist("/work/users/file1.sas7bdat")) AND %sysfunc(fileexist("/work/users/file2.sas7bdat"))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/* CHECK IF SAS DATASETS ARE READY */&lt;/P&gt;&lt;P&gt;%macro fex;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/* Here I want this to resolve to 1 if both files exist and to 0 otherwise */&lt;/P&gt;&lt;P&gt; %do %until ( %eval(%unquote(%qsysfunc(compress(&amp;amp;untils,*)))) );&lt;/P&gt;&lt;P&gt;&amp;nbsp; %put NOTE: Not There Yet!;&lt;/P&gt;&lt;P&gt;&amp;nbsp; %macro sleep;&lt;/P&gt;&lt;P&gt;&amp;nbsp; data _null_; x = sleep(1000); run;&lt;/P&gt;&lt;P&gt;&amp;nbsp; %mend sleep;&lt;/P&gt;&lt;P&gt;&amp;nbsp; %sleep;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; dm 'clear log';&lt;/P&gt;&lt;P&gt; %end;&lt;/P&gt;&lt;P&gt;%mend fex;&lt;/P&gt;&lt;P&gt;%fex;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The %macro fex fails with the following errors:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ERROR: Expected close parenthesis after macro function invocation not found.&lt;/P&gt;&lt;P&gt;ERROR: %EVAL function has no expression to evaluate, or %IF statement has no condition.&lt;/P&gt;&lt;P&gt;ERROR: %EVAL function has no expression to evaluate, or %IF statement has no condition.&lt;/P&gt;&lt;P&gt;ERROR: The condition in the %DO %UNTIL loop, %eval(%unquote(%qsysfunc(compress(&amp;amp;untils,*)))), yielded an invalid or missing value, . &lt;/P&gt;&lt;P&gt;The macro will stop executing.&lt;/P&gt;&lt;P&gt;ERROR: The macro FEX will stop executing.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please help me resolve this issue!&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 21 Mar 2013 16:36:14 GMT</pubDate>
    <dc:creator>keyreal</dc:creator>
    <dc:date>2013-03-21T16:36:14Z</dc:date>
    <item>
      <title>Check multiple files existence in a %DO %UNTIL macro...</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Check-multiple-files-existence-in-a-DO-UNTIL-macro/m-p/84976#M18273</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a table with a single column (sas_datasets) that has the names of files as its values, i.e.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;sas_datasets&lt;/P&gt;&lt;P&gt;-------------------------------------&lt;/P&gt;&lt;P&gt;/work/users/file1.sas7bdat&lt;/P&gt;&lt;P&gt;/work/users/file2.sas7bdat&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I use the following&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/* Note that I inserted the asterisk (*) after the percent sign (%) below to prevent it from evaluating to 0, instead I need it as text */&lt;/P&gt;&lt;P&gt;proc sql noprint; &lt;/P&gt;&lt;P&gt;select cats('%*sysfunc(fileexist(','"',sas_datasets,'"))')&lt;/P&gt;&lt;P&gt;into :untils &lt;/P&gt;&lt;P&gt;separated by ' AND ' &lt;/P&gt;&lt;P&gt;from sas_datasets&lt;/P&gt;&lt;P&gt;;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/* Here I remove the asterisk */&lt;/P&gt;&lt;P&gt;%put NOTE: %qsysfunc(compress(&amp;amp;untils,*));&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;resolves to&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%sysfunc(fileexist("/work/users/file1.sas7bdat")) AND %sysfunc(fileexist("/work/users/file2.sas7bdat"))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/* CHECK IF SAS DATASETS ARE READY */&lt;/P&gt;&lt;P&gt;%macro fex;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/* Here I want this to resolve to 1 if both files exist and to 0 otherwise */&lt;/P&gt;&lt;P&gt; %do %until ( %eval(%unquote(%qsysfunc(compress(&amp;amp;untils,*)))) );&lt;/P&gt;&lt;P&gt;&amp;nbsp; %put NOTE: Not There Yet!;&lt;/P&gt;&lt;P&gt;&amp;nbsp; %macro sleep;&lt;/P&gt;&lt;P&gt;&amp;nbsp; data _null_; x = sleep(1000); run;&lt;/P&gt;&lt;P&gt;&amp;nbsp; %mend sleep;&lt;/P&gt;&lt;P&gt;&amp;nbsp; %sleep;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; dm 'clear log';&lt;/P&gt;&lt;P&gt; %end;&lt;/P&gt;&lt;P&gt;%mend fex;&lt;/P&gt;&lt;P&gt;%fex;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The %macro fex fails with the following errors:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ERROR: Expected close parenthesis after macro function invocation not found.&lt;/P&gt;&lt;P&gt;ERROR: %EVAL function has no expression to evaluate, or %IF statement has no condition.&lt;/P&gt;&lt;P&gt;ERROR: %EVAL function has no expression to evaluate, or %IF statement has no condition.&lt;/P&gt;&lt;P&gt;ERROR: The condition in the %DO %UNTIL loop, %eval(%unquote(%qsysfunc(compress(&amp;amp;untils,*)))), yielded an invalid or missing value, . &lt;/P&gt;&lt;P&gt;The macro will stop executing.&lt;/P&gt;&lt;P&gt;ERROR: The macro FEX will stop executing.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please help me resolve this issue!&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Mar 2013 16:36:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Check-multiple-files-existence-in-a-DO-UNTIL-macro/m-p/84976#M18273</guid>
      <dc:creator>keyreal</dc:creator>
      <dc:date>2013-03-21T16:36:14Z</dc:date>
    </item>
    <item>
      <title>Re: Check multiple files existence in a %DO %UNTIL macro...</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Check-multiple-files-existence-in-a-DO-UNTIL-macro/m-p/84977#M18274</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would suggest %DO %WHILE instead.&amp;nbsp; Something like blow maybe?&lt;/P&gt;&lt;PRE&gt;data sasdatasets;
&amp;nbsp; input datasetname $41.;
cards;
work.a
work.b
;
run;

%macro dosomething(dummy);

%local AllPresent i;
%let i=1;

proc sql noprint;
&amp;nbsp; select min(exist(datasetname)) into : AllPresent
&amp;nbsp; from sasdatasets;
quit;

%do %while (&amp;amp;allPresent=0 and &amp;amp;i&lt;BR /&gt;
&lt;P&gt;--Q.&lt;/P&gt;

&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Mar 2013 16:56:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Check-multiple-files-existence-in-a-DO-UNTIL-macro/m-p/84977#M18274</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2013-03-21T16:56:46Z</dc:date>
    </item>
    <item>
      <title>Re: Check multiple files existence in a %DO %UNTIL macro...</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Check-multiple-files-existence-in-a-DO-UNTIL-macro/m-p/84978#M18275</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Looks like my first post was truncated by a LT character which loooked like an open tag....&lt;/P&gt;&lt;PRE&gt;data sasdatasets;
&amp;nbsp; input datasetname $41.;
cards;
work.a
work.b
;
run;

%macro dosomething(dummy);

%local AllPresent i;
%let i=1;

proc sql noprint;
&amp;nbsp; select min(exist(datasetname)) into :AllPresent
&amp;nbsp; from sasdatasets;
quit;

%do %while (&amp;amp;allPresent=0 and &amp;amp;i lt 10);
&amp;nbsp; %put i=&amp;amp;i Not all here yet;
&amp;nbsp; %let dummy=%sysfunc(sleep(1));
&amp;nbsp; %let i=%eval(&amp;amp;i+1);
%end;

%mend dosomething;

%dosomething()
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: Quentin McMullen&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Mar 2013 17:57:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Check-multiple-files-existence-in-a-DO-UNTIL-macro/m-p/84978#M18275</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2013-03-21T17:57:15Z</dc:date>
    </item>
    <item>
      <title>Re: Check multiple files existence in a %DO %UNTIL macro...</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Check-multiple-files-existence-in-a-DO-UNTIL-macro/m-p/84979#M18276</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Quentin, thank you for you responses!&lt;/P&gt;&lt;P&gt;I think the problem is not whether to use UNTIL or WHILE loop but rather the fact that&lt;/P&gt;&lt;P&gt;the macro variable that resolves to this statement does not work in the loop:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%sysfunc(fileexist("/work/users/file1.sas7bdat")) AND %sysfunc(fileexist("/work/users/file2.sas7bdat"))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also, the fact that I have the filenames in the table does not mean that they already exist. I just know what the file naming convention is, but the files themselves are not yet being created. Therefore, I use DO UNTIL to constantly (at certain frequency) pass the file existence statement repeatedly until both files exist. I think it has to do with macro quoting but I cannot figure it out.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Mar 2013 19:27:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Check-multiple-files-existence-in-a-DO-UNTIL-macro/m-p/84979#M18276</guid>
      <dc:creator>keyreal</dc:creator>
      <dc:date>2013-03-21T19:27:37Z</dc:date>
    </item>
    <item>
      <title>Re: Check multiple files existence in a %DO %UNTIL macro...</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Check-multiple-files-existence-in-a-DO-UNTIL-macro/m-p/84980#M18277</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;keyreal,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Worth a try, to isolate the problem.&amp;nbsp; Instead of adding a complex argument to %do %until, use a simple one:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%do %until (&amp;amp;result=1);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; ...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; %let result = %eval(%unquote(etc.));&lt;/P&gt;&lt;P&gt;%end;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;On a side note, when %sysfunc calls fileexist, the quotes around the file names are optional.&amp;nbsp; If it's simpler for you, you could remove them.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good luck.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Mar 2013 19:59:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Check-multiple-files-existence-in-a-DO-UNTIL-macro/m-p/84980#M18277</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2013-03-21T19:59:57Z</dc:date>
    </item>
    <item>
      <title>Re: Check multiple files existence in a %DO %UNTIL macro...</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Check-multiple-files-existence-in-a-DO-UNTIL-macro/m-p/84981#M18278</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Minor note, you probably should move the definition of the Macro SLEEP out of the FEX macro. You are recreating the exact same macro in each step through the loop. If this is a place holder for another macro as a test it could be even more effecient not to recompile the macro multiple times.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Mar 2013 20:29:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Check-multiple-files-existence-in-a-DO-UNTIL-macro/m-p/84981#M18278</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2013-03-21T20:29:29Z</dc:date>
    </item>
    <item>
      <title>Re: Check multiple files existence in a %DO %UNTIL macro...</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Check-multiple-files-existence-in-a-DO-UNTIL-macro/m-p/84982#M18279</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you all for your suggestions! I finally figured it out!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/* I needed to mask the %-sign in the sysfunc using %nrstr() at compilation */&lt;/P&gt;&lt;P&gt;proc sql noprint; &lt;/P&gt;&lt;P&gt;select cats('%nrstr(%sysfunc)(fileexist(','"',sas_datasets,'"))')&lt;/P&gt;&lt;P&gt;into :untils &lt;/P&gt;&lt;P&gt;separated by ' AND ' &lt;/P&gt;&lt;P&gt;from sas_datasets&lt;/P&gt;&lt;P&gt;;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;SPAN lang="EN"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;/* CHECK IF SAS DATASETS ARE READY */&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;SPAN lang="EN"&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;%macro fex;&lt;/P&gt;&lt;P&gt;/* Here I evaluate the existence of multiple files to be 1 if all of them exist and 0 otherwise */&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;SPAN lang="EN"&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;%do %until ( %eval(%unquote(&amp;amp;untils)) );&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;SPAN lang="EN"&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;%put NOTE: File does NOT exist!;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;SPAN lang="EN"&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;%macro sleep;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;SPAN lang="EN"&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;data _null_; x = sleep(1000); run;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;SPAN lang="EN"&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;%mend sleep;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;SPAN lang="EN"&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;%sleep;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;SPAN lang="EN"&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;dm 'clear log';&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;SPAN lang="EN"&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;%end;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;SPAN lang="EN"&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;%mend fex;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;SPAN lang="EN"&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;%fex;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;SPAN lang="EN"&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;%put NOTE: ************* SUCCESS!!!!!!;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;SPAN lang="EN"&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Mar 2013 21:22:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Check-multiple-files-existence-in-a-DO-UNTIL-macro/m-p/84982#M18279</guid>
      <dc:creator>keyreal</dc:creator>
      <dc:date>2013-03-21T21:22:36Z</dc:date>
    </item>
    <item>
      <title>Re: Check multiple files existence in a %DO %UNTIL macro...</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Check-multiple-files-existence-in-a-DO-UNTIL-macro/m-p/84983#M18280</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Only benefit of %DO WHILE is that if they did both exist on the first iteration, you wouldn't have to sleep.&amp;nbsp;&amp;nbsp;&amp;nbsp; But agree that's a small point.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Did you try my example?&amp;nbsp; I think it's doing what you want.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;--Q.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Mar 2013 21:25:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Check-multiple-files-existence-in-a-DO-UNTIL-macro/m-p/84983#M18280</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2013-03-21T21:25:01Z</dc:date>
    </item>
    <item>
      <title>Re: Check multiple files existence in a %DO %UNTIL macro...</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Check-multiple-files-existence-in-a-DO-UNTIL-macro/m-p/84984#M18281</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Again,&lt;/P&gt;&lt;P&gt;Glad you got it working.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Below is what I had meant to suggest.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;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,&amp;nbsp; 0 if any does not exist.&amp;nbsp; So it's an alternate approach that avoids the macro quoting headaches.&amp;nbsp; 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.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I used exist instead of fileexist as a convenience, since they are SAS dataasets.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;data sasdatasets;
&amp;nbsp; 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;
&amp;nbsp; select min(exist(datasetname)) into :AllPresent
&amp;nbsp; 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 (&amp;amp;allPresent=0 and &amp;amp;i le 10);&amp;nbsp; 
&amp;nbsp; %put Iter#&amp;amp;i: Missing at least one dataset, sleep and try again.;
&amp;nbsp; %let dummy=%sysfunc(sleep(5));

&amp;nbsp; %*Check to see if they all exist now;
&amp;nbsp; proc sql noprint;
&amp;nbsp;&amp;nbsp;&amp;nbsp; select min(exist(datasetname)) into :AllPresent
&amp;nbsp;&amp;nbsp;&amp;nbsp; from sasdatasets;
&amp;nbsp; quit;

&amp;nbsp; %let i=%eval(&amp;amp;i+1);
%end;

%if &amp;amp;allPresent=1 %then %do;
&amp;nbsp; %put All datasets exist! Continue processing...;&lt;BR /&gt;&amp;nbsp; %* Main code /macro call here;
%end;
%else %if &amp;amp;allPresent=0 %then %do;
&amp;nbsp; %put Giving up! Still missing at least one dataset.;
%end;

%mend dosomething;

%dosomething()
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Mar 2013 00:46:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Check-multiple-files-existence-in-a-DO-UNTIL-macro/m-p/84984#M18281</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2013-03-22T00:46:06Z</dc:date>
    </item>
  </channel>
</rss>

