<?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: macro call error in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/macro-call-error/m-p/333881#M272174</link>
    <description>&lt;P&gt;That post was written to illustrate calling a macro in a loop. macro_call is just a stand-in for any macro you need to execute repeatedly.&lt;/P&gt;</description>
    <pubDate>Fri, 17 Feb 2017 18:25:39 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2017-02-17T18:25:39Z</dc:date>
    <item>
      <title>macro call error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-call-error/m-p/333846#M272171</link>
      <description>&lt;P&gt;&amp;nbsp;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have started to figure out how can I use do loop in macro and I ran the below code (I found from this website). but I got error.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the code:&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro control (list=, start_date=, end_date=);
   %local list;
   %do i=1 %to %sysfunc(countw(&amp;amp;list));
      %let key = %scan(&amp;amp;list,&amp;amp;i);
      %let key2= %scan(&amp;amp;start_date,&amp;amp;i); /* you already had the pattern for this statement*/
      %let key3= %scan(&amp;amp;start_date,&amp;amp;i);

       %macro_call(&amp;amp;key,&amp;amp;key2,&amp;amp;key3);
   %end;
%mend;

%control(list=1234 2456 3567 4567 5674 8765,
         start_date= 03-SEP-16  10-SEP-16 17-SEP-16 24-SEP-16 01-OCT16,
         end_date  = 09-SEP-16 16-SEP-16 23-SEP-16 30-SEP-16 07-OCT-16 );&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;and I got following error:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV class="sasSource"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="sasError"&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; 114                 %macro_call(&amp;amp;key,&amp;amp;key2,&amp;amp;key3);
                     _
                     180
 
 ERROR 180-322: Statement is not valid or it is used out of proper order.
 
 MLOGIC(CONTROL):  %DO loop index variable I is now 7; loop will not iterate again.&lt;/CODE&gt;&lt;/PRE&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="sasError"&gt;Thanks for any help;&lt;/DIV&gt;&lt;DIV class="sasError"&gt;Samira&lt;/DIV&gt;</description>
      <pubDate>Fri, 17 Feb 2017 17:15:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-call-error/m-p/333846#M272171</guid>
      <dc:creator>samira</dc:creator>
      <dc:date>2017-02-17T17:15:25Z</dc:date>
    </item>
    <item>
      <title>Re: macro call error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-call-error/m-p/333858#M272172</link>
      <description>&lt;P&gt;Is there actually a macro called "macro_call" defined and compiled somewhere?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I think the code you have is using it as an example of how to invoke one macro within another, but that macro has to exist.&lt;/P&gt;</description>
      <pubDate>Fri, 17 Feb 2017 17:30:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-call-error/m-p/333858#M272172</guid>
      <dc:creator>collinelliot</dc:creator>
      <dc:date>2017-02-17T17:30:44Z</dc:date>
    </item>
    <item>
      <title>Re: macro call error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-call-error/m-p/333861#M272173</link>
      <description>&lt;P&gt;no actually that is all I have in my program. I am very new in SAS and I was trying to figure out how can I use such loops. and I thought macro_call is a defult statement in SAS. isn't? &amp;nbsp;If not how can I print out the variable within loop?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;yes I found the code at :&amp;nbsp;&lt;A href="https://communities.sas.com/t5/Base-SAS-Programming/How-can-access-a-macro-do-loop-or-do-loop-only-for-a-list-of/m-p/301779#M63921&amp;nbsp;" target="_blank"&gt;https://communities.sas.com/t5/Base-SAS-Programming/How-can-access-a-macro-do-loop-or-do-loop-only-for-a-list-of/m-p/301779#M63921&amp;nbsp;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for the reply!&lt;/P&gt;</description>
      <pubDate>Fri, 17 Feb 2017 17:43:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-call-error/m-p/333861#M272173</guid>
      <dc:creator>samira</dc:creator>
      <dc:date>2017-02-17T17:43:24Z</dc:date>
    </item>
    <item>
      <title>Re: macro call error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-call-error/m-p/333881#M272174</link>
      <description>&lt;P&gt;That post was written to illustrate calling a macro in a loop. macro_call is just a stand-in for any macro you need to execute repeatedly.&lt;/P&gt;</description>
      <pubDate>Fri, 17 Feb 2017 18:25:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-call-error/m-p/333881#M272174</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-02-17T18:25:39Z</dc:date>
    </item>
    <item>
      <title>Re: macro call error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-call-error/m-p/333899#M272175</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/98482"&gt;@samira&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;no actually that is all I have in my program. I am very new in SAS and I was trying to figure out how can I use such loops. and I thought macro_call is a defult statement in SAS. isn't? &amp;nbsp;If not how can I print out the variable within loop?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;yes I found the code at :&amp;nbsp;&lt;A href="https://communities.sas.com/t5/Base-SAS-Programming/How-can-access-a-macro-do-loop-or-do-loop-only-for-a-list-of/m-p/301779#M63921" target="_blank"&gt;https://communities.sas.com/t5/Base-SAS-Programming/How-can-access-a-macro-do-loop-or-do-loop-only-for-a-list-of/m-p/301779#M63921&amp;nbsp;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for the reply!&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;To see the result of what you have done so far instead of the macro call use&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="token macroname"&gt;%put key=&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;&amp;amp;&lt;/SPAN&gt;key key2=&lt;SPAN class="token operator"&gt;&amp;amp;&lt;/SPAN&gt;key2 key3=&lt;SPAN class="token operator"&gt;&amp;amp;&lt;/SPAN&gt;key3&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 17 Feb 2017 19:08:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-call-error/m-p/333899#M272175</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-02-17T19:08:21Z</dc:date>
    </item>
    <item>
      <title>Re: macro call error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-call-error/m-p/334129#M272176</link>
      <description>&lt;P&gt;Since you don't actually have another macro that you are calling (yet) then just put in a %PUT statement so you can see what vlaues you have assigned.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%put (&amp;amp;key1,&amp;amp;key2,&amp;amp;key3);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Also you do not need to add a %LOCAL statement for the macro parameters. They will already be local macro variables. &amp;nbsp;Instead you should define the macro variables you are creating as local. Otherwise you might change the values of existing macro variables.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%local i key1 key2 key3;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Note you also probably want to define KEY3 to take the value from the list of end dates instead of getting another copy of the start date.&lt;/P&gt;</description>
      <pubDate>Sat, 18 Feb 2017 21:39:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-call-error/m-p/334129#M272176</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-02-18T21:39:22Z</dc:date>
    </item>
  </channel>
</rss>

