<?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: Pass a macro variable to a macro? in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Pass-a-macro-variable-to-a-macro/m-p/124364#M34179</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A __default_attr="815014" __jive_macro_name="user" class="jive_macro jive_macro_user" data-objecttype="3" href="https://communities.sas.com/"&gt;&lt;/A&gt; and &lt;A __default_attr="255172" __jive_macro_name="user" class="jive_macro jive_macro_user" data-objecttype="3" href="https://communities.sas.com/"&gt;&lt;/A&gt;.&amp;nbsp; You both indicated that one can't pass a variable to a macro and I know that you are both more knowledgeable than I am regarding macros.&amp;nbsp; However, if one can't do it, why does the following work?:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let beg_date=01sep2013;&lt;/P&gt;&lt;P&gt;%let end_date=30sep2013;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro month_end (dt);&lt;/P&gt;&lt;P&gt;&amp;nbsp; put &amp;amp;dt. worddate.;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;&amp;nbsp; do i = "&amp;amp;beg_date."d to "&amp;amp;end_date."d;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; %month_end(i);&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 25 Oct 2013 20:17:35 GMT</pubDate>
    <dc:creator>art297</dc:creator>
    <dc:date>2013-10-25T20:17:35Z</dc:date>
    <item>
      <title>Pass a macro variable to a macro?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Pass-a-macro-variable-to-a-macro/m-p/124358#M34173</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have created a macro that gets executed for everyday of the month.&amp;nbsp; In the code below &amp;amp;beg_date and &amp;amp;end_date represent the first date and last date of a month (i.e. 20130901 and 20130930).&amp;nbsp; They have already been defined in previous steps.&amp;nbsp; The problem is with the "i" in the do loop.&amp;nbsp; The "i" seems to work just fine with the "put i" statement.&amp;nbsp; However, when I call the macro %month_end it does not reconize the i being paseed. The log says "Macro variable DT resolves to &amp;amp;i.".&amp;nbsp; I have posted my code below.&amp;nbsp; If anyone has a different approach (not using the do loop) I would love to hear it.&amp;nbsp; Any input would be greatly appreciated &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Just a little more information, I am trying to run the macro 30 times and the value of "dt" should be from 20130901 to 20130930. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro month_end (dt);&lt;/P&gt;&lt;P&gt;data aaa_&amp;amp;dt.;&lt;/P&gt;&lt;P&gt;XXXXX&lt;/P&gt;&lt;P&gt;run;&lt;BR /&gt;%mend;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;do i = &amp;amp;beg_date. to &amp;amp;end_date.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; put i;&lt;/P&gt;&lt;P&gt;&amp;nbsp; %month_end(&amp;amp;i.);&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 25 Oct 2013 19:27:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Pass-a-macro-variable-to-a-macro/m-p/124358#M34173</guid>
      <dc:creator>KevinC_</dc:creator>
      <dc:date>2013-10-25T19:27:11Z</dc:date>
    </item>
    <item>
      <title>Re: Pass a macro variable to a macro?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Pass-a-macro-variable-to-a-macro/m-p/124359#M34174</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You are trying to pass a non-existent macro variable. I think you meant to type:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp; %month_end(i);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 25 Oct 2013 19:40:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Pass-a-macro-variable-to-a-macro/m-p/124359#M34174</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2013-10-25T19:40:52Z</dc:date>
    </item>
    <item>
      <title>Re: Pass a macro variable to a macro?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Pass-a-macro-variable-to-a-macro/m-p/124360#M34175</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You have no macro variable set up as &amp;amp;i, but a data step variable i (No %do/%to).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Either move the loop to macro code or use call execute to call the macro instead.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;EDITED&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 25 Oct 2013 19:41:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Pass-a-macro-variable-to-a-macro/m-p/124360#M34175</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2013-10-25T19:41:07Z</dc:date>
    </item>
    <item>
      <title>Re: Pass a macro variable to a macro?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Pass-a-macro-variable-to-a-macro/m-p/124361#M34176</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You're talking about passing the value of a data step variable to a macro, not a macro variable.&amp;nbsp; You can't pass the value of i (not &amp;amp;i, that doesn't exist in this code).&amp;nbsp; You can pass the variable name, which then can be used in the macro like a normal variable name - you don't say what your code is doing so no idea if that's helpful or not.&amp;nbsp; But you can't pass the value stored in i to the macro in the way you're going about it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What you could do is use CALL EXECUTE to call the macro, if it's doing things outside of a datastep anyway, something like&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;data _null_;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;do i = &amp;amp;beg_date. to &amp;amp;end_date.;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp; put i;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp; callstr=cats('%month_end(',i,'.);');&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp; call execute (callstr);&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;end;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;run;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;What that would do is run all of the macro iterations after the data step finished running.&amp;nbsp; If that's not helpful you'll have to describe what the macro is doing (ie, post the macro or some equivalent).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 25 Oct 2013 19:42:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Pass-a-macro-variable-to-a-macro/m-p/124361#M34176</guid>
      <dc:creator>snoopy369</dc:creator>
      <dc:date>2013-10-25T19:42:01Z</dc:date>
    </item>
    <item>
      <title>Re: Pass a macro variable to a macro?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Pass-a-macro-variable-to-a-macro/m-p/124362#M34177</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you, Authur, Reeza, and Snoopy369,&amp;nbsp; for your suggestions !&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Snoopy369,&lt;/P&gt;&lt;P&gt;I tried your code but is your callstr= cats statement missing a ")"? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you all again!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 25 Oct 2013 20:00:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Pass-a-macro-variable-to-a-macro/m-p/124362#M34177</guid>
      <dc:creator>KevinC_</dc:creator>
      <dc:date>2013-10-25T20:00:24Z</dc:date>
    </item>
    <item>
      <title>Re: Pass a macro variable to a macro?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Pass-a-macro-variable-to-a-macro/m-p/124363#M34178</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ah indeed, corrected.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 25 Oct 2013 20:02:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Pass-a-macro-variable-to-a-macro/m-p/124363#M34178</guid>
      <dc:creator>snoopy369</dc:creator>
      <dc:date>2013-10-25T20:02:02Z</dc:date>
    </item>
    <item>
      <title>Re: Pass a macro variable to a macro?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Pass-a-macro-variable-to-a-macro/m-p/124364#M34179</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A __default_attr="815014" __jive_macro_name="user" class="jive_macro jive_macro_user" data-objecttype="3" href="https://communities.sas.com/"&gt;&lt;/A&gt; and &lt;A __default_attr="255172" __jive_macro_name="user" class="jive_macro jive_macro_user" data-objecttype="3" href="https://communities.sas.com/"&gt;&lt;/A&gt;.&amp;nbsp; You both indicated that one can't pass a variable to a macro and I know that you are both more knowledgeable than I am regarding macros.&amp;nbsp; However, if one can't do it, why does the following work?:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let beg_date=01sep2013;&lt;/P&gt;&lt;P&gt;%let end_date=30sep2013;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro month_end (dt);&lt;/P&gt;&lt;P&gt;&amp;nbsp; put &amp;amp;dt. worddate.;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;&amp;nbsp; do i = "&amp;amp;beg_date."d to "&amp;amp;end_date."d;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; %month_end(i);&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 25 Oct 2013 20:17:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Pass-a-macro-variable-to-a-macro/m-p/124364#M34179</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2013-10-25T20:17:35Z</dc:date>
    </item>
    <item>
      <title>Re: Pass a macro variable to a macro?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Pass-a-macro-variable-to-a-macro/m-p/124365#M34180</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Because you are passing the variable name 'i' to the macro, and then you are executing&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;put i worddate.;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;in the macro.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 25 Oct 2013 20:28:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Pass-a-macro-variable-to-a-macro/m-p/124365#M34180</guid>
      <dc:creator>snoopy369</dc:creator>
      <dc:date>2013-10-25T20:28:45Z</dc:date>
    </item>
    <item>
      <title>Re: Pass a macro variable to a macro?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Pass-a-macro-variable-to-a-macro/m-p/124366#M34181</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I didn't say you couldn't, but not a solution I offered &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 25 Oct 2013 20:33:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Pass-a-macro-variable-to-a-macro/m-p/124366#M34181</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2013-10-25T20:33:41Z</dc:date>
    </item>
    <item>
      <title>Re: Pass a macro variable to a macro?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Pass-a-macro-variable-to-a-macro/m-p/124367#M34182</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you to all of you for your input!&amp;nbsp; &lt;/P&gt;&lt;P&gt;I played with all different approaches suggested by you.&amp;nbsp; I decided to put my do loop inside a macro and pass i as a macro variable.&amp;nbsp; The code worked beautifully.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you all again!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 25 Oct 2013 21:25:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Pass-a-macro-variable-to-a-macro/m-p/124367#M34182</guid>
      <dc:creator>KevinC_</dc:creator>
      <dc:date>2013-10-25T21:25:31Z</dc:date>
    </item>
    <item>
      <title>Re: Pass a macro variable to a macro?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Pass-a-macro-variable-to-a-macro/m-p/124368#M34183</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hey guys,&lt;/P&gt;&lt;P&gt;what's with the dots after "beg_date" and "end_date" in your codes ?&lt;/P&gt;&lt;P&gt;i tried the codes and they are running without them too so what&amp;nbsp; s the use of it.Can someone explain please? &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 29 Oct 2013 03:00:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Pass-a-macro-variable-to-a-macro/m-p/124368#M34183</guid>
      <dc:creator>Tal</dc:creator>
      <dc:date>2013-10-29T03:00:14Z</dc:date>
    </item>
    <item>
      <title>Re: Pass a macro variable to a macro?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Pass-a-macro-variable-to-a-macro/m-p/124369#M34184</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;See: &lt;A class="active_link" href="http://support.sas.com/documentation/cdl/en/mcrolref/61885/HTML/default/viewer.htm#a001071889.htm" title="http://support.sas.com/documentation/cdl/en/mcrolref/61885/HTML/default/viewer.htm#a001071889.htm"&gt;SAS(R) 9.2 Macro Language: Reference&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The periods usually aren't necessary, but may be.&amp;nbsp; You are always, I think, safest including them.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 29 Oct 2013 03:10:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Pass-a-macro-variable-to-a-macro/m-p/124369#M34184</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2013-10-29T03:10:11Z</dc:date>
    </item>
    <item>
      <title>Re: Pass a macro variable to a macro?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Pass-a-macro-variable-to-a-macro/m-p/124370#M34185</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;thank you&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 29 Oct 2013 03:19:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Pass-a-macro-variable-to-a-macro/m-p/124370#M34185</guid>
      <dc:creator>Tal</dc:creator>
      <dc:date>2013-10-29T03:19:39Z</dc:date>
    </item>
  </channel>
</rss>

