<?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: how to call macro under a loop in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/how-to-call-macro-under-a-loop/m-p/361826#M85387</link>
    <description>&lt;P&gt;Don't use a macro to call another macro. Use Call Execute.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13711"&gt;@art297&lt;/a&gt;&amp;nbsp;'s answer is correct, except I'd strip the macro entirely.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;  data _null_;
    array dtloop {2} $ ('0107' '0207');
    length forexec $80;
    do i=1 to 2;
       forexec=catt('%actdat(',dtloop(i),')');
       call execute(forexec);
    end;&lt;BR /&gt;run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 26 May 2017 00:02:03 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2017-05-26T00:02:03Z</dc:date>
    <item>
      <title>how to call macro under a loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-call-macro-under-a-loop/m-p/361817#M85384</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a SAS macro, which only has one parameter related to date, and I tried to call it several times per its date. In order&amp;nbsp; not to copy and paste several times, I tried to write another macro to call it.However, I got an error and&amp;nbsp;I could&amp;nbsp;not run through it.&amp;nbsp;Below is a little more details.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SAS macro whose parameter is date like this:&lt;/P&gt;
&lt;P&gt;%macro actdat(date1);&lt;/P&gt;
&lt;P&gt;;;;;;;;&lt;/P&gt;
&lt;P&gt;%mend;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Simple way to call that macro is like this:&lt;/P&gt;
&lt;P&gt;%actdat(0107);&lt;/P&gt;
&lt;P&gt;%actdat(0207);&lt;/P&gt;
&lt;P&gt;;;;;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What I wrote another macro to call it like this:&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;%macro&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; &lt;STRONG&gt;&lt;I&gt;alldate&lt;/I&gt;&lt;/STRONG&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt; array dtloop {&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;2&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;} $ (&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'0107'&lt;/FONT&gt; &lt;FONT color="#800080" face="Courier New" size="3"&gt;'0207'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%do&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; i=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%to&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;2&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;%let a=dtloop{i};&lt;/P&gt;
&lt;P&gt;%actdat(symget(&amp;amp;a.));&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%end&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;%mend&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%&lt;STRONG&gt;&lt;I&gt;alldate&lt;/I&gt;&lt;/STRONG&gt;;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any idea what's wrong with this? And how to correct this?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Thu, 25 May 2017 23:18:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-call-macro-under-a-loop/m-p/361817#M85384</guid>
      <dc:creator>lucky66</dc:creator>
      <dc:date>2017-05-25T23:18:48Z</dc:date>
    </item>
    <item>
      <title>Re: how to call macro under a loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-call-macro-under-a-loop/m-p/361823#M85385</link>
      <description>&lt;P&gt;You could try (not tested):&lt;/P&gt;
&lt;PRE&gt;%macro alldate;

  data _null_;
    array dtloop {2} $ ('0107' '0207');
    length forexec $80;
    do i=1 to 2;
       forexec=catt('%actdat(',dtloop(i),')');
       call execute(forexec);
    end;
  run;
%mend;
 
%alldate;
&lt;/PRE&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;</description>
      <pubDate>Thu, 25 May 2017 23:50:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-call-macro-under-a-loop/m-p/361823#M85385</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-05-25T23:50:39Z</dc:date>
    </item>
    <item>
      <title>Re: how to call macro under a loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-call-macro-under-a-loop/m-p/361826#M85387</link>
      <description>&lt;P&gt;Don't use a macro to call another macro. Use Call Execute.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13711"&gt;@art297&lt;/a&gt;&amp;nbsp;'s answer is correct, except I'd strip the macro entirely.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;  data _null_;
    array dtloop {2} $ ('0107' '0207');
    length forexec $80;
    do i=1 to 2;
       forexec=catt('%actdat(',dtloop(i),')');
       call execute(forexec);
    end;&lt;BR /&gt;run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 26 May 2017 00:02:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-call-macro-under-a-loop/m-p/361826#M85387</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-05-26T00:02:03Z</dc:date>
    </item>
    <item>
      <title>Re: how to call macro under a loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-call-macro-under-a-loop/m-p/361833#M85391</link>
      <description>&lt;P&gt;You may also try:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro alldates(dates);
   %let n = %sysfunc(countw(&amp;amp;dates));
    %do i=1 %to &amp;amp;n;
          %let a = %scan(&amp;amp;dates , &amp;amp;i);
           %actdat(&amp;amp;a.);
    %end;
%mend;
 
%alldates(0107 0207);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 26 May 2017 00:38:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-call-macro-under-a-loop/m-p/361833#M85391</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2017-05-26T00:38:56Z</dc:date>
    </item>
    <item>
      <title>Re: how to call macro under a loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-call-macro-under-a-loop/m-p/361836#M85393</link>
      <description>&lt;P&gt;Hi ART297,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;it works, thanks so much.&lt;/P&gt;</description>
      <pubDate>Fri, 26 May 2017 00:47:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-call-macro-under-a-loop/m-p/361836#M85393</guid>
      <dc:creator>lucky66</dc:creator>
      <dc:date>2017-05-26T00:47:03Z</dc:date>
    </item>
    <item>
      <title>Re: how to call macro under a loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-call-macro-under-a-loop/m-p/361899#M85430</link>
      <description>&lt;P&gt;It seems to me your just layering macro on top of macro for no purpose here. &amp;nbsp;Nothing of the information you have provided would indicate something not possible in base SAS. &amp;nbsp;There are many ways to approach a problem, for instance rather than dates as parameters you could pass in a dataset with all the dates to be worked on, this effectively means one call. &amp;nbsp;Or you can do it in a datastep, no macro needed at all, or you could transpose/normalise your data etc. &amp;nbsp;As you can see many methods. &amp;nbsp;99.9% of the time you should either re-modelling the data, or figuring out use of Base SAS functions will result in simpler, easier to maintain code.&lt;/P&gt;</description>
      <pubDate>Fri, 26 May 2017 08:18:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-call-macro-under-a-loop/m-p/361899#M85430</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-05-26T08:18:19Z</dc:date>
    </item>
  </channel>
</rss>

