<?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: Call Macro serveral times with incrementing the parameter in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Call-Macro-serveral-times-with-incrementing-the-parameter/m-p/784780#M250433</link>
    <description>&lt;P&gt;Your requirements are unclear, is it:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;repeat each call 200 times&lt;/LI&gt;
&lt;LI&gt;increment by 6 for each macro call up to 200&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;Assuming the first one, use a data step loop and CALL EXECUTE. Modification for the second one is pretty straightforward in a data step as well.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data demo_run_macro;

increment=6;
do i=1 to 200;
      str = catt('%weeks(week=', i*increment, ');');
      call execute(str);
end;

run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/409173"&gt;@CM64&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I'd like to call a macro 200 times and increment the parameter with each call, but I don't want to repeat each call 200 times.&amp;nbsp; Is there a %do %loop that can provide what I need?&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;%macro Weeks(week=);&lt;BR /&gt;proc sort data=in.test1 out=test1_W&amp;amp;week. (keep=subject); by subject; where folder="WEEK&amp;amp;week."; run;&lt;BR /&gt;run;&lt;BR /&gt;%mend;&lt;BR /&gt;%Weeks(Week=6); *increment by 6 for each macro call up to 200;&lt;BR /&gt;%Weeks(Week=12);&lt;BR /&gt;%Weeks(Week=18);&lt;BR /&gt;.&lt;BR /&gt;.&lt;BR /&gt;.&lt;BR /&gt;%Weeks(Week=200);&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 07 Dec 2021 23:00:15 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2021-12-07T23:00:15Z</dc:date>
    <item>
      <title>Call Macro serveral times with incrementing the parameter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Call-Macro-serveral-times-with-incrementing-the-parameter/m-p/784779#M250432</link>
      <description>&lt;P&gt;I'd like to call a macro 200 times and increment the parameter with each call, but I don't want to repeat each call 200 times.&amp;nbsp; Is there a %do %loop that can provide what I need?&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;%macro Weeks(week=);&lt;BR /&gt;proc sort data=in.test1 out=test1_W&amp;amp;week. (keep=subject); by subject; where folder="WEEK&amp;amp;week."; run;&lt;BR /&gt;run;&lt;BR /&gt;%mend;&lt;BR /&gt;%Weeks(Week=6); *increment by 6 for each macro call up to 200;&lt;BR /&gt;%Weeks(Week=12);&lt;BR /&gt;%Weeks(Week=18);&lt;BR /&gt;.&lt;BR /&gt;.&lt;BR /&gt;.&lt;BR /&gt;%Weeks(Week=200);&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Dec 2021 22:53:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Call-Macro-serveral-times-with-incrementing-the-parameter/m-p/784779#M250432</guid>
      <dc:creator>CM64</dc:creator>
      <dc:date>2021-12-07T22:53:16Z</dc:date>
    </item>
    <item>
      <title>Re: Call Macro serveral times with incrementing the parameter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Call-Macro-serveral-times-with-incrementing-the-parameter/m-p/784780#M250433</link>
      <description>&lt;P&gt;Your requirements are unclear, is it:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;repeat each call 200 times&lt;/LI&gt;
&lt;LI&gt;increment by 6 for each macro call up to 200&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;Assuming the first one, use a data step loop and CALL EXECUTE. Modification for the second one is pretty straightforward in a data step as well.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data demo_run_macro;

increment=6;
do i=1 to 200;
      str = catt('%weeks(week=', i*increment, ');');
      call execute(str);
end;

run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/409173"&gt;@CM64&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I'd like to call a macro 200 times and increment the parameter with each call, but I don't want to repeat each call 200 times.&amp;nbsp; Is there a %do %loop that can provide what I need?&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;%macro Weeks(week=);&lt;BR /&gt;proc sort data=in.test1 out=test1_W&amp;amp;week. (keep=subject); by subject; where folder="WEEK&amp;amp;week."; run;&lt;BR /&gt;run;&lt;BR /&gt;%mend;&lt;BR /&gt;%Weeks(Week=6); *increment by 6 for each macro call up to 200;&lt;BR /&gt;%Weeks(Week=12);&lt;BR /&gt;%Weeks(Week=18);&lt;BR /&gt;.&lt;BR /&gt;.&lt;BR /&gt;.&lt;BR /&gt;%Weeks(Week=200);&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Dec 2021 23:00:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Call-Macro-serveral-times-with-incrementing-the-parameter/m-p/784780#M250433</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-12-07T23:00:15Z</dc:date>
    </item>
    <item>
      <title>Re: Call Macro serveral times with incrementing the parameter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Call-Macro-serveral-times-with-incrementing-the-parameter/m-p/784794#M250442</link>
      <description>&lt;P&gt;To increment by 6 use the BY keyword on a DO loop.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename code temp;
data _null_;
  file code;
  do week=6 to 200 by 6 ;
    put '%weeks(' week= ')';
  end;
run;
%include code / source2;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 08 Dec 2021 00:10:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Call-Macro-serveral-times-with-incrementing-the-parameter/m-p/784794#M250442</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-12-08T00:10:41Z</dc:date>
    </item>
  </channel>
</rss>

