<?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 use loops for macro function calls in SAS in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-loops-for-macro-function-calls-in-SAS/m-p/300078#M63350</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%Let Macro_List=bbbbbbINFY bbbbbbSBIN bbbbbbbTCS;
%Macro Loop;
%Do i=1 %To %Sysfunc(CountW(&amp;amp;Macro_List.));
  %Let Param=%Scan(&amp;amp;Macro_List.,&amp;amp;i.);
  %loopit(26062015,&amp;amp;Param.,FUTSTK,30Jul2015);
%End;
%Mend;
%Loop&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 22 Sep 2016 11:19:24 GMT</pubDate>
    <dc:creator>user24feb</dc:creator>
    <dc:date>2016-09-22T11:19:24Z</dc:date>
    <item>
      <title>How to use loops for macro function calls in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-loops-for-macro-function-calls-in-SAS/m-p/300067#M63345</link>
      <description>&lt;P&gt;I am using the following statements for function calls in sas&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%loopit(26062015,bbbbbbINFY,FUTSTK,30Jul2015);
%loopit(26062015,bbbbbbSBIN,FUTSTK,30Jul2015);
%loopit(26062015,bbbbbbbTCS,FUTSTK,30Jul2015);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;BR /&gt;where i have already have defined the loopit macro previously in the code. As it can be seen, in the function calls, only one parameter changes while the rest are same. I wanted to if there are any loop structures (e.g. Arrays) I can use to make it more useful.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Sep 2016 10:08:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-loops-for-macro-function-calls-in-SAS/m-p/300067#M63345</guid>
      <dc:creator>Anirban</dc:creator>
      <dc:date>2016-09-22T10:08:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to use loops for macro function calls in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-loops-for-macro-function-calls-in-SAS/m-p/300070#M63346</link>
      <description>&lt;P&gt;If your parameters are in a data set look into CALL EXECUTE to call your macro. &amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Sep 2016 10:14:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-loops-for-macro-function-calls-in-SAS/m-p/300070#M63346</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-09-22T10:14:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to use loops for macro function calls in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-loops-for-macro-function-calls-in-SAS/m-p/300073#M63347</link>
      <description>&lt;P&gt;Put the control values into a dataset, or do the call execute from a &lt;FONT face="courier new,courier"&gt;cards;&lt;/FONT&gt; block:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
input loop_val $10.;
call execute('%loopit(26062015,'!!loop_val!!',FUTSTK,30Jul2015);');
cards;
bbbbbbINFY
bbbbbbSBIN
bbbbbbbTCS
;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 22 Sep 2016 10:28:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-loops-for-macro-function-calls-in-SAS/m-p/300073#M63347</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-09-22T10:28:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to use loops for macro function calls in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-loops-for-macro-function-calls-in-SAS/m-p/300076#M63348</link>
      <description>&lt;P&gt;Why are you doing that in the first place? &amp;nbsp;Datasteps are a loop, and have all the data structures and syntax necessary to perform such tasks. &amp;nbsp;So simplfy your code to:&lt;/P&gt;
&lt;PRE&gt;data want;
  set have;
  do i="bbbbbINFY","bbbbbSBIN","bbbbbTCS";
    /* some code */
  end;
run;&lt;/PRE&gt;
&lt;P&gt;Macro language is not a replacement for Base SAS.&lt;/P&gt;</description>
      <pubDate>Thu, 22 Sep 2016 10:52:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-loops-for-macro-function-calls-in-SAS/m-p/300076#M63348</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-09-22T10:52:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to use loops for macro function calls in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-loops-for-macro-function-calls-in-SAS/m-p/300078#M63350</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%Let Macro_List=bbbbbbINFY bbbbbbSBIN bbbbbbbTCS;
%Macro Loop;
%Do i=1 %To %Sysfunc(CountW(&amp;amp;Macro_List.));
  %Let Param=%Scan(&amp;amp;Macro_List.,&amp;amp;i.);
  %loopit(26062015,&amp;amp;Param.,FUTSTK,30Jul2015);
%End;
%Mend;
%Loop&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 22 Sep 2016 11:19:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-loops-for-macro-function-calls-in-SAS/m-p/300078#M63350</guid>
      <dc:creator>user24feb</dc:creator>
      <dc:date>2016-09-22T11:19:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to use loops for macro function calls in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-loops-for-macro-function-calls-in-SAS/m-p/300126#M63362</link>
      <description>&lt;P&gt;If your macro is mostly going to be used with the same values you can use keyword parameters to set a default value to reduce how much is entered.&lt;/P&gt;
&lt;P&gt;Obviously I do not know your macro variable names but this should give you an idea;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%macro &lt;SPAN class="token macroname"&gt;%loopit&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(D1 =&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;26062015&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;, str=&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;, Var2=&lt;/SPAN&gt;FUTSTK&lt;SPAN class="token punctuation"&gt;, Date=&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;30&lt;/SPAN&gt;Jul2015&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token punctuation"&gt;Then the call would look like&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token punctuation"&gt;&lt;SPAN class="token macroname"&gt;%loopit&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;Str=&lt;/SPAN&gt;bbbbbbINFY&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token punctuation"&gt;&lt;SPAN class="token punctuation"&gt;The values for the other parameters would be as defined in the macro.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token punctuation"&gt;&lt;SPAN class="token punctuation"&gt;If you need to use a different value for one of those parameters such as date:&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token punctuation"&gt;&lt;SPAN class="token punctuation"&gt;&lt;SPAN class="token macroname"&gt;%loopit&lt;/SPAN&gt;(&lt;SPAN class="token number"&gt;Str=&lt;/SPAN&gt;bbbbbbINFY, Date= 08Aug2016);&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token punctuation"&gt;&lt;SPAN class="token punctuation"&gt;&lt;SPAN class="token punctuation"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Sep 2016 14:48:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-loops-for-macro-function-calls-in-SAS/m-p/300126#M63362</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-09-22T14:48:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to use loops for macro function calls in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-loops-for-macro-function-calls-in-SAS/m-p/300290#M63406</link>
      <description>&lt;P&gt;Thanks for your solution. It really helped. Now I have created a Dataset with the list of the scrips and using call execute to call the macro as suggested.&lt;/P&gt;</description>
      <pubDate>Fri, 23 Sep 2016 06:28:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-loops-for-macro-function-calls-in-SAS/m-p/300290#M63406</guid>
      <dc:creator>Anirban</dc:creator>
      <dc:date>2016-09-23T06:28:43Z</dc:date>
    </item>
  </channel>
</rss>

