<?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 Re: %do %while in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/do-while/m-p/556218#M154941</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro team;
%macro av(ot=);
data ag;
    path="&amp;amp;ot";
	output;
run;
%mend;

option mlogic merror symbolgen;
 
%let pathlist=%superq(pathlist);

%put &amp;amp;pathlist;
* Generate Macro List for all the paths in each tab;
%let pathlist=%superq(pathlist);
%do i=1 %to %sysfunc(countw(&amp;amp;pathlist,|));
  %let path=%scan(&amp;amp;pathlist,&amp;amp;i,|);
	%put &amp;amp;path;
     %av(ot=&amp;amp;path);
         
	%LET i=%EVAL(&amp;amp;i. + 1);
%END;

%mend team;

%team;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;i updated code as per your suggestion and its working.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;but its not executing for for 2nd value.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;my pathlistvalue=&lt;/P&gt;&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token datalines"&gt;&lt;SPAN class="token data string"&gt;\\\gmt\rtg-yup99\ststic\myfolder\folder\study\2007\adam\Pdng\Pgmm|\\\gmt\rtg-yup99\ststic\myfolder\folder\study\2007\adam\Pdng\ot&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;its execute first value only.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;its not taking 2nd value after |&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 04 May 2019 20:43:13 GMT</pubDate>
    <dc:creator>sam1231</dc:creator>
    <dc:date>2019-05-04T20:43:13Z</dc:date>
    <item>
      <title>%do %while</title>
      <link>https://communities.sas.com/t5/SAS-Programming/do-while/m-p/556191#M154923</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;option mlogic merror symbolgen;
 
* Generate Macro List for all the paths in each tab;
  %let pathlist= &amp;amp;prodpro;
  %put &amp;amp;pathlist;

 %let i=1;
%DO %WHILE (%SCAN(&amp;amp;pathlist,&amp;amp;i,")") ne %STR( ));
	%LET path=%SCAN(&amp;amp;pathlist,&amp;amp;i,")");
	%put &amp;amp;path;

	
%put "Reading &amp;amp;dsn.";
     %genexcel(dir=&amp;amp;path);
	%LET i=%EVAL(&amp;amp;i. + 1);
%END;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;STRONG&gt;above code is giving me below error&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;FONT color="#FF0000"&gt;ERROR: Macro function %SCAN has too few arguments.&lt;/FONT&gt;&lt;BR /&gt;SYMBOLGEN: Macro variable I resolves to 1&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;ERROR: Required operator not found in expression: %SCAN(&amp;amp;pathlist,&amp;amp;i,")") ne&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;ERROR: The condition in the %DO %WHILE loop, %SCAN(&amp;amp;pathlist,&amp;amp;i,")") ne &amp;#1; &amp;#2;, yielded an invalid&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;or missing value, . The macro will stop executing.&lt;/FONT&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;My pathlist value is&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;\\\gmt\rtg-yup99\ststic\myfolder\folder\study\2007\adam\Pdng\Pgmm)&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please can some help me?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;</description>
      <pubDate>Sat, 04 May 2019 15:45:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/do-while/m-p/556191#M154923</guid>
      <dc:creator>sam1231</dc:creator>
      <dc:date>2019-05-04T15:45:49Z</dc:date>
    </item>
    <item>
      <title>Re: %do %while</title>
      <link>https://communities.sas.com/t5/SAS-Programming/do-while/m-p/556193#M154924</link>
      <description>&lt;P&gt;The value of your macro variable is confusing the macro processor.&lt;/P&gt;
&lt;PRE&gt;289   %let string=xxx);
290   %let word1=%scan(&amp;amp;string,1);
ERROR: Macro function %SCAN has too few arguments.&lt;/PRE&gt;
&lt;P&gt;Look at what code you asked SAS to interpret.&lt;/P&gt;
&lt;PRE&gt;291   %put scan(&amp;amp;string,1);
scan(xxx),1)&lt;/PRE&gt;
&lt;P&gt;Add some macro quoting. Since you seem to be making a new macro variable why not just add the macro quoting when making that variable.&amp;nbsp; Also eliminate the quotes from the list of delimiters you are asking %SCAN() to use otherwise you will get unexpected results when the path list includes quotes.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let prodpro=\\\gmt\rtg-yup99\ststic\myfolder\folder\study\2007\adam\Pdng\Pgmm);
%let pathlist= %superq(prodpro);
%do i=1 %to %sysfunc(countw(&amp;amp;pathlist,%str(%))));
  %let path=%scan(&amp;amp;pathlist,&amp;amp;i,%str(%)));&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 04 May 2019 16:16:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/do-while/m-p/556193#M154924</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-05-04T16:16:03Z</dc:date>
    </item>
    <item>
      <title>Re: %do %while</title>
      <link>https://communities.sas.com/t5/SAS-Programming/do-while/m-p/556210#M154934</link>
      <description>&lt;P&gt;Thank you tom! its working&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But i am trying to apply below&amp;nbsp; 4 %let macro variable&amp;nbsp; to one macro variable&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%let pathlist=%superq(prodpro prodpro1 prodpro2 prodpro3);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token macroname"&gt;%let&lt;/SPAN&gt; prodpro&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;\&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;\&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;\&lt;/SPAN&gt;gmt&lt;SPAN class="token punctuation"&gt;\&lt;/SPAN&gt;rtg&lt;SPAN class="token operator"&gt;-&lt;/SPAN&gt;yup99&lt;SPAN class="token punctuation"&gt;\&lt;/SPAN&gt;ststic&lt;SPAN class="token punctuation"&gt;\&lt;/SPAN&gt;myfolder&lt;SPAN class="token punctuation"&gt;\&lt;/SPAN&gt;folder&lt;SPAN class="token punctuation"&gt;\&lt;/SPAN&gt;study&lt;SPAN class="token punctuation"&gt;\&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;2007&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;\&lt;/SPAN&gt;adam&lt;SPAN class="token punctuation"&gt;\&lt;/SPAN&gt;Pdng&lt;SPAN class="token punctuation"&gt;\&lt;/SPAN&gt;Pgmm&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token macroname"&gt;%let&lt;/SPAN&gt; prodpro1&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;\&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;\&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;\&lt;/SPAN&gt;gmt&lt;SPAN class="token punctuation"&gt;\&lt;/SPAN&gt;rtg&lt;SPAN class="token operator"&gt;-&lt;/SPAN&gt;yup99&lt;SPAN class="token punctuation"&gt;\&lt;/SPAN&gt;ststic&lt;SPAN class="token punctuation"&gt;\&lt;/SPAN&gt;myfolder&lt;SPAN class="token punctuation"&gt;\&lt;/SPAN&gt;folder&lt;SPAN class="token punctuation"&gt;\&lt;/SPAN&gt;study&lt;SPAN class="token punctuation"&gt;\&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;2007&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;\&lt;/SPAN&gt;adam&lt;SPAN class="token punctuation"&gt;\&lt;/SPAN&gt;Pdng&lt;SPAN class="token punctuation"&gt;\ot&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token macroname"&gt;%let&lt;/SPAN&gt; prodpro2&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;\&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;\&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;\&lt;/SPAN&gt;gmt&lt;SPAN class="token punctuation"&gt;\&lt;/SPAN&gt;rtg&lt;SPAN class="token operator"&gt;-&lt;/SPAN&gt;yup99&lt;SPAN class="token punctuation"&gt;\&lt;/SPAN&gt;ststic&lt;SPAN class="token punctuation"&gt;\&lt;/SPAN&gt;myfolder&lt;SPAN class="token punctuation"&gt;\&lt;/SPAN&gt;folder&lt;SPAN class="token punctuation"&gt;\&lt;/SPAN&gt;study&lt;SPAN class="token punctuation"&gt;\&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;2007&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;\&lt;/SPAN&gt;adam&lt;SPAN class="token punctuation"&gt;\&lt;/SPAN&gt;Pdng&lt;SPAN class="token punctuation"&gt;\lst&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token macroname"&gt;%let&lt;/SPAN&gt; prodpro3&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;\&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;\&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;\&lt;/SPAN&gt;gmt&lt;SPAN class="token punctuation"&gt;\&lt;/SPAN&gt;rtg&lt;SPAN class="token operator"&gt;-&lt;/SPAN&gt;yup99&lt;SPAN class="token punctuation"&gt;\&lt;/SPAN&gt;ststic&lt;SPAN class="token punctuation"&gt;\&lt;/SPAN&gt;myfolder&lt;SPAN class="token punctuation"&gt;\&lt;/SPAN&gt;folder&lt;SPAN class="token punctuation"&gt;\&lt;/SPAN&gt;study&lt;SPAN class="token punctuation"&gt;\&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;2007&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;\&lt;/SPAN&gt;adam&lt;SPAN class="token punctuation"&gt;\&lt;/SPAN&gt;Pdng&lt;SPAN class="token punctuation"&gt;\gfh&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i want to run my macro loop for 4 time(for each and every path). do you have any suggestions?&lt;/P&gt;</description>
      <pubDate>Sat, 04 May 2019 19:07:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/do-while/m-p/556210#M154934</guid>
      <dc:creator>sam1231</dc:creator>
      <dc:date>2019-05-04T19:07:32Z</dc:date>
    </item>
    <item>
      <title>Re: %do %while</title>
      <link>https://communities.sas.com/t5/SAS-Programming/do-while/m-p/556211#M154935</link>
      <description>&lt;P&gt;The %SUPERQ() function takes the name of a single macro variable.&lt;/P&gt;
&lt;P&gt;You could combine the values first.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let pathlist=&amp;amp;prodpro.&amp;amp;prodpro1.&amp;amp;prodpro2.&amp;amp;prodpro3;
%let pathlist=%superq(pathlist);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If that is your real goal then change your scan logic to use some other character as the delimiter. For example you could use | since that is invalid to include in a real path.&amp;nbsp; That will also mean that most likely you will not need to apply any macro quoting to your paths.&amp;nbsp; But if you allow silly things like "Joe's Files" as part of the path then the unbalanced single quote will still need to macro quoting.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data pathlist;
  infile cards truncover ;
  input path $200.;
cards;
\\\gmt\rtg-yup99\ststic\myfolder\folder\study\2007\adam\Pdng\Pgmm
\\\gmt\rtg-yup99\ststic\myfolder\folder\study\2007\adam\Pdng\ot
\\\gmt\rtg-yup99\ststic\myfolder\folder\study\2007\adam\Pdng\lst
\\\gmt\rtg-yup99\ststic\myfolder\folder\study\2007\adam\Pdng\gfh
;

proc sql noprint;
 select path into :pathlist separated by '|'
  from pathlist 
 ;
quit;
%let pathlist=%superq(pathlist);
.....
%do i=1 %to %sysfunc(countw(&amp;amp;pathlist,|));
  %let path=%scan(&amp;amp;pathlist,|);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 04 May 2019 19:36:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/do-while/m-p/556211#M154935</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-05-04T19:36:31Z</dc:date>
    </item>
    <item>
      <title>Re: %do %while</title>
      <link>https://communities.sas.com/t5/SAS-Programming/do-while/m-p/556218#M154941</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro team;
%macro av(ot=);
data ag;
    path="&amp;amp;ot";
	output;
run;
%mend;

option mlogic merror symbolgen;
 
%let pathlist=%superq(pathlist);

%put &amp;amp;pathlist;
* Generate Macro List for all the paths in each tab;
%let pathlist=%superq(pathlist);
%do i=1 %to %sysfunc(countw(&amp;amp;pathlist,|));
  %let path=%scan(&amp;amp;pathlist,&amp;amp;i,|);
	%put &amp;amp;path;
     %av(ot=&amp;amp;path);
         
	%LET i=%EVAL(&amp;amp;i. + 1);
%END;

%mend team;

%team;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;i updated code as per your suggestion and its working.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;but its not executing for for 2nd value.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;my pathlistvalue=&lt;/P&gt;&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token datalines"&gt;&lt;SPAN class="token data string"&gt;\\\gmt\rtg-yup99\ststic\myfolder\folder\study\2007\adam\Pdng\Pgmm|\\\gmt\rtg-yup99\ststic\myfolder\folder\study\2007\adam\Pdng\ot&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;its execute first value only.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;its not taking 2nd value after |&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 04 May 2019 20:43:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/do-while/m-p/556218#M154941</guid>
      <dc:creator>sam1231</dc:creator>
      <dc:date>2019-05-04T20:43:13Z</dc:date>
    </item>
    <item>
      <title>Re: %do %while</title>
      <link>https://communities.sas.com/t5/SAS-Programming/do-while/m-p/556222#M154943</link>
      <description>&lt;P&gt;The way you have coded your loop you are counting by twos.&amp;nbsp; 1,3,5,7.&lt;/P&gt;
&lt;P&gt;remove the extra increment to the loop counter.&lt;/P&gt;</description>
      <pubDate>Sat, 04 May 2019 21:55:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/do-while/m-p/556222#M154943</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-05-04T21:55:38Z</dc:date>
    </item>
  </channel>
</rss>

