<?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 Character Parameter Dynamically to a Macro in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Pass-Character-Parameter-Dynamically-to-a-Macro/m-p/411299#M100541</link>
    <description>&lt;P&gt;You're a rockstar! Thanks!&lt;/P&gt;</description>
    <pubDate>Tue, 07 Nov 2017 18:25:51 GMT</pubDate>
    <dc:creator>SteelersPitts</dc:creator>
    <dc:date>2017-11-07T18:25:51Z</dc:date>
    <item>
      <title>Pass Character Parameter Dynamically to a Macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Pass-Character-Parameter-Dynamically-to-a-Macro/m-p/411255#M100534</link>
      <description>&lt;P&gt;I'm trying to pass file name to a macro. The macro runs once a month, therefore, I'm trying to store the output file with a month prefix. In the current code someone has to manually provide a file name every month (Sep17_Sales, Oct17_Sales etc.). I want to automate this so that SAS generates files with the name of the month prefixed to the data file.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;Macro:&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;&lt;P&gt;%macro sales (outdata = , dt =);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;Current Code&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;&lt;P&gt;%Sales(Outdata = Sep17_Sales, dt = '2017-09-01');&lt;/P&gt;&lt;P&gt;%Sales(Outdata =Oct17_Sales, dt ='2017-10-01');&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;My approach:&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;current_date = today();&lt;/P&gt;&lt;P&gt;current_month = intnx('month', current_date, 0, "Beginning");&lt;/P&gt;&lt;P&gt;Name = "_Sales";&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;Result&lt;/FONT&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;= put(current_month, monyy7.) || name;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;%Sales(Outdata=&lt;FONT color="#FF0000"&gt;Result&lt;/FONT&gt;, dt='2017-10-01');&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I try to pass the parameter, it throws error.&amp;nbsp; I tried changing Result to %Let Result and pass a reference &amp;amp;Result to the macro but it also fails.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any suggestion how to solve this? Thank you for all the help!!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Nov 2017 17:09:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Pass-Character-Parameter-Dynamically-to-a-Macro/m-p/411255#M100534</guid>
      <dc:creator>SteelersPitts</dc:creator>
      <dc:date>2017-11-07T17:09:49Z</dc:date>
    </item>
    <item>
      <title>Re: Pass Character Parameter Dynamically to a Macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Pass-Character-Parameter-Dynamically-to-a-Macro/m-p/411260#M100535</link>
      <description>&lt;P&gt;Well beginning is spelt incorrectly to start with.&lt;/P&gt;
&lt;P&gt;Anyways, in your macro can you not just do:&lt;/P&gt;
&lt;PRE&gt;filename "&amp;lt;pathtofile&amp;gt;\%sysfunc(put(month(today(),monname3.)))_rest_of_name.txt";
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Nov 2017 17:06:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Pass-Character-Parameter-Dynamically-to-a-Macro/m-p/411260#M100535</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-11-07T17:06:15Z</dc:date>
    </item>
    <item>
      <title>Re: Pass Character Parameter Dynamically to a Macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Pass-Character-Parameter-Dynamically-to-a-Macro/m-p/411264#M100538</link>
      <description>&lt;P&gt;You've gotten most of the way there.&amp;nbsp; But as you have seen, macro calls do not use DATA step variables.&amp;nbsp; Here is a way to bridge that gap.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;First, finish your DATA step with:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#ff0000"&gt;Result&lt;/FONT&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;= put(current_month, monyy7.) || name;&lt;/P&gt;
&lt;P&gt;call symputx('result_value', result);&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then call the macro with:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%Sales(Outdata=&amp;amp;result_value, dt='2017-10-01')&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There are many ways to get to that same end result.&amp;nbsp; This one utilizes what you have done so far, while making very few changes.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note that it might be possible to automatically generate the second parameter in similar fashion.&lt;/P&gt;</description>
      <pubDate>Tue, 07 Nov 2017 17:18:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Pass-Character-Parameter-Dynamically-to-a-Macro/m-p/411264#M100538</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-11-07T17:18:32Z</dc:date>
    </item>
    <item>
      <title>Re: Pass Character Parameter Dynamically to a Macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Pass-Character-Parameter-Dynamically-to-a-Macro/m-p/411299#M100541</link>
      <description>&lt;P&gt;You're a rockstar! Thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 07 Nov 2017 18:25:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Pass-Character-Parameter-Dynamically-to-a-Macro/m-p/411299#M100541</guid>
      <dc:creator>SteelersPitts</dc:creator>
      <dc:date>2017-11-07T18:25:51Z</dc:date>
    </item>
  </channel>
</rss>

