<?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: Calling a Macro with Macro  Variable as Parameter in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Calling-a-Macro-with-Macro-Variable-as-Parameter/m-p/463720#M118190</link>
    <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/128563"&gt;@V_R&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;...or to avoid the issues&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt; mentiones first populate a SAS variable and use this one in your call execute() as parameter. For my brain that's easier to read and debug.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  set control;
  length cmd $200;
  cmd=cats('%a(',date,')');
  call execute(cmd);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 21 May 2018 07:14:37 GMT</pubDate>
    <dc:creator>Patrick</dc:creator>
    <dc:date>2018-05-21T07:14:37Z</dc:date>
    <item>
      <title>Calling a Macro with Macro  Variable as Parameter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calling-a-Macro-with-Macro-Variable-as-Parameter/m-p/463707#M118185</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a macro like following&lt;/P&gt;&lt;P&gt;%Macro a(date);&lt;/P&gt;&lt;P&gt;Other Statements here;&lt;/P&gt;&lt;P&gt;%Mend;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now i want to call the macro basis dates like following&lt;/P&gt;&lt;P&gt;%a(20180401);&lt;/P&gt;&lt;P&gt;%a(20180402);&lt;/P&gt;&lt;P&gt;%a(20180403);&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;%a(20180430);&lt;/P&gt;&lt;P&gt;how can i call a macro, without manually type date or calling a macro 30 times,every time i call a macro.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;One way i can think of is creating a dataset which include dates for the month and creating a macro variable list.&lt;/P&gt;&lt;P&gt;however i dont know how to pass these macro variable one by one without typing them manually&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 21 May 2018 06:12:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calling-a-Macro-with-Macro-Variable-as-Parameter/m-p/463707#M118185</guid>
      <dc:creator>V_R</dc:creator>
      <dc:date>2018-05-21T06:12:00Z</dc:date>
    </item>
    <item>
      <title>Re: Calling a Macro with Macro  Variable as Parameter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calling-a-Macro-with-Macro-Variable-as-Parameter/m-p/463710#M118187</link>
      <description>&lt;P&gt;This is done with call execute within the data step:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
set control;
call execute('%nrstr(%a(' !! strip(date) !! '))');
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The %nrstr prevents premature execution of macro statements within the macro.&lt;/P&gt;</description>
      <pubDate>Mon, 21 May 2018 06:19:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calling-a-Macro-with-Macro-Variable-as-Parameter/m-p/463710#M118187</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-05-21T06:19:56Z</dc:date>
    </item>
    <item>
      <title>Re: Calling a Macro with Macro  Variable as Parameter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calling-a-Macro-with-Macro-Variable-as-Parameter/m-p/463720#M118190</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/128563"&gt;@V_R&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;...or to avoid the issues&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt; mentiones first populate a SAS variable and use this one in your call execute() as parameter. For my brain that's easier to read and debug.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  set control;
  length cmd $200;
  cmd=cats('%a(',date,')');
  call execute(cmd);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 21 May 2018 07:14:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calling-a-Macro-with-Macro-Variable-as-Parameter/m-p/463720#M118190</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2018-05-21T07:14:37Z</dc:date>
    </item>
    <item>
      <title>Re: Calling a Macro with Macro  Variable as Parameter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calling-a-Macro-with-Macro-Variable-as-Parameter/m-p/463768#M118200</link>
      <description>&lt;P&gt;Alternatively, write a second macro to perform the looping:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%macro loop (start=, finish=);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; %local date;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; %do date = &amp;amp;start %to &amp;amp;finish;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %a (&amp;amp;date)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; %end;&lt;/P&gt;
&lt;P&gt;%mend loop;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%loop (start=20180401, finish=20180430)&lt;/P&gt;</description>
      <pubDate>Mon, 21 May 2018 12:45:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calling-a-Macro-with-Macro-Variable-as-Parameter/m-p/463768#M118200</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-05-21T12:45:04Z</dc:date>
    </item>
    <item>
      <title>Re: Calling a Macro with Macro  Variable as Parameter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calling-a-Macro-with-Macro-Variable-as-Parameter/m-p/463771#M118202</link>
      <description>&lt;P&gt;Actually&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12447"&gt;@Patrick&lt;/a&gt;, you still need %NRSTR() to avoid the timing issues&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;described, which arise if the called macro creates a macro variable from data.&amp;nbsp; As an example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data control ;
  do date=today()-5 to today() ;
    output ;
  end ;
run ;

%macro a(date) ;
  data _null_ ;
    call symputx('macvar','1','L') ;
  run ;
  %put &amp;amp;=date &amp;amp;=macvar;
%mend a ;

*Warning message because MACVAR is attempted to resolve before the data _null_ step executes;
data _null_;
  set control;
  length cmd $200;
  cmd=cats('%a(',date,')');
  call execute(cmd);
run;

*Cleanup (MACVAR was created in global scope) ;
%symdel macvar;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When you add %NRSTR() the call execute generates the macro call, but it does not actually execute the macro.&amp;nbsp; This makes the timing work out.&amp;nbsp; Also makes the log cleaner, because the CALL EXECUTE section just shows the generated macro call(s):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  set control;
  length cmd $200;
  cmd=cats('%nrstr(%a(',date,'))');
  call execute(cmd);
run;

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 21 May 2018 13:08:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calling-a-Macro-with-Macro-Variable-as-Parameter/m-p/463771#M118202</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2018-05-21T13:08:44Z</dc:date>
    </item>
  </channel>
</rss>

