<?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 Nested %do %while-loops inside a macro in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Nested-do-while-loops-inside-a-macro/m-p/531192#M5862</link>
    <description>&lt;P&gt;Hello community,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to make a %do %while nested loop here, can you please check if there is an error? because when I run the code it iterates for&amp;nbsp; CHAN A and the 12 month but it closes and didn't&amp;nbsp; do chan B....&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let CHAN=A B C D E;
%let MONTH=JAN FEB MAR APR MAY JUN JUL AGO SEP OCT NOV DEC;

%macro TEST ();

%local i j month_1 chan_1;
%let j=1;
%let i=1;

%do %while (%scan(&amp;amp;chan, &amp;amp;j.) ne );
%let chan_1 = %scan(&amp;amp;chan, &amp;amp;j.);

%do %while (%scan(&amp;amp;month, &amp;amp;i.) ne );
%let month_1 = %scan(&amp;amp;month, &amp;amp;i.);

 /*SOME STEPS HERE*/

   %let i = %eval(&amp;amp;i. + 1);
  
%end;
%let j = %eval(&amp;amp;j. + 1);
%end;

%mend TEST;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Using&amp;nbsp; SAS EG&amp;nbsp;7.13&lt;/P&gt;</description>
    <pubDate>Tue, 29 Jan 2019 21:44:16 GMT</pubDate>
    <dc:creator>Scorpx</dc:creator>
    <dc:date>2019-01-29T21:44:16Z</dc:date>
    <item>
      <title>Nested %do %while-loops inside a macro</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Nested-do-while-loops-inside-a-macro/m-p/531192#M5862</link>
      <description>&lt;P&gt;Hello community,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to make a %do %while nested loop here, can you please check if there is an error? because when I run the code it iterates for&amp;nbsp; CHAN A and the 12 month but it closes and didn't&amp;nbsp; do chan B....&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let CHAN=A B C D E;
%let MONTH=JAN FEB MAR APR MAY JUN JUL AGO SEP OCT NOV DEC;

%macro TEST ();

%local i j month_1 chan_1;
%let j=1;
%let i=1;

%do %while (%scan(&amp;amp;chan, &amp;amp;j.) ne );
%let chan_1 = %scan(&amp;amp;chan, &amp;amp;j.);

%do %while (%scan(&amp;amp;month, &amp;amp;i.) ne );
%let month_1 = %scan(&amp;amp;month, &amp;amp;i.);

 /*SOME STEPS HERE*/

   %let i = %eval(&amp;amp;i. + 1);
  
%end;
%let j = %eval(&amp;amp;j. + 1);
%end;

%mend TEST;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Using&amp;nbsp; SAS EG&amp;nbsp;7.13&lt;/P&gt;</description>
      <pubDate>Tue, 29 Jan 2019 21:44:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Nested-do-while-loops-inside-a-macro/m-p/531192#M5862</guid>
      <dc:creator>Scorpx</dc:creator>
      <dc:date>2019-01-29T21:44:16Z</dc:date>
    </item>
    <item>
      <title>Re: Nested %do %while-loops inside a macro</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Nested-do-while-loops-inside-a-macro/m-p/531201#M5865</link>
      <description>&lt;P&gt;You forgot to reset I.&lt;/P&gt;
&lt;P&gt;Move the %LET I=1 inside the outer loop.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Why are you incrementing the loop counter yourself? Why not just let SAS do that?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%do j=1 %to %sysfunc(countw(&amp;amp;chan));
  %let chan_1 = %scan(&amp;amp;chan, &amp;amp;j.);
  %do i=1 %to %sysfunc(countw(&amp;amp;month));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Jan 2019 22:43:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Nested-do-while-loops-inside-a-macro/m-p/531201#M5865</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-01-29T22:43:14Z</dc:date>
    </item>
    <item>
      <title>Re: Nested %do %while-loops inside a macro</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Nested-do-while-loops-inside-a-macro/m-p/531351#M5889</link>
      <description>&lt;P&gt;Thank you Tom,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I did work with your suggestion!&lt;/P&gt;</description>
      <pubDate>Wed, 30 Jan 2019 12:53:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Nested-do-while-loops-inside-a-macro/m-p/531351#M5889</guid>
      <dc:creator>Scorpx</dc:creator>
      <dc:date>2019-01-30T12:53:25Z</dc:date>
    </item>
  </channel>
</rss>

