<?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 variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/macro-variable/m-p/801920#M315643</link>
    <description>&lt;P&gt;There are two ways to create arguments to a macro ... with an equal sign, and without an equal sign&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Without an equal sign (this is what you did)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro gen_base(Portofo,dev);
data &amp;amp;Portofo._VAL (KEEP= MOB DQ_6);
set monthly.score_&amp;amp;Portofo.(keep=account_no CURR_DELQMONTH_ON_BOOK bad);
....
run;
%mend;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In this case the order of the variables in the call to the macro is critical&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%gen_base(old_gwic_others_&amp;amp;P_YYMMDD.,Gwic_old_others)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;means that &amp;amp;PORTOFO = old_gwic_others_&amp;amp;P_YYMMDD. and &amp;amp;DEV = Gwic_old_others&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or, if you reverse the order&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%gen_base(Gwic_old_others,old_gwic_others_&amp;amp;P_YYMMDD.)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;this means that &amp;amp;PORTOFO = Gwic_old_others and &amp;amp;DEV =&amp;nbsp;old_gwic_others_&amp;amp;P_YYMMDD.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;With equal signs, the order they are called is irrelevant&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro gen_base(Portofo=,dev=);
data &amp;amp;Portofo._VAL (KEEP= MOB DQ_6);
set monthly.score_&amp;amp;Portofo.(keep=account_no CURR_DELQMONTH_ON_BOOK bad);
....
run;
%mend;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then both of these produce the exact same results:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%gen_base(portofo = old_gwic_others_&amp;amp;P_YYMMDD., dev = Gwic_old_others)
%gen_base(dev = Gwic_old_others, portofo = old_gwic_others_&amp;amp;P_YYMMDD.)&lt;/CODE&gt;&amp;nbsp;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I strongly recommend the style where you use the equal signs, as this removes any ambiguity about which macro variable has which value. It probably doesn't matter if your macro has one or two arguments, but if you write a macro with lots of arguments, without the equal signs you will have to keep track of which argument is the 6th, and which argument is the 7th, and so on; this is easy to get wrong. If you use the equal signs, then it is always clear which macro variable is getting which value.&lt;/P&gt;</description>
    <pubDate>Mon, 14 Mar 2022 14:14:25 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2022-03-14T14:14:25Z</dc:date>
    <item>
      <title>macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-variable/m-p/801908#M315634</link>
      <description>&lt;PRE&gt;%macro gen_base(Portofo,dev)
data &amp;amp;Portofo._VAL (KEEP= MOB DQ_6);
set monthly.score_&amp;amp;Portofo.(keep=account_no CURR_DELQMONTH_ON_BOOK bad);
....
run;
gen_base(old_gwic_others_&amp;amp;P_YYMMDD.,Gwic_old_others);&lt;/PRE&gt;
&lt;P&gt;Hi All I am having the above code and I am not sure what is the value of&amp;nbsp;&amp;amp;Portofo._VAL on the second line , the data line.&lt;/P&gt;
&lt;P&gt;should it be old_gwic_others_&amp;amp;P_YYMMDD.? or&amp;nbsp;old_gwic_others_&amp;amp;P_YYMMDD._VAL...&lt;/P&gt;
&lt;P&gt;and &amp;amp;dev would be "Gwic_old_others"&lt;/P&gt;</description>
      <pubDate>Mon, 14 Mar 2022 09:21:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-variable/m-p/801908#M315634</guid>
      <dc:creator>HeatherNewton</dc:creator>
      <dc:date>2022-03-14T09:21:25Z</dc:date>
    </item>
    <item>
      <title>Re: macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-variable/m-p/801909#M315635</link>
      <description>&lt;PRE&gt;&lt;SPAN&gt;%gen_base(old_gwic_others_&amp;amp;P_YYMMDD.,Gwic_old_others);&lt;BR /&gt;&lt;/SPAN&gt;
data &amp;amp;Portofo._VAL (KEEP= MOB DQ_6);  &amp;gt;&amp;gt;&amp;gt; &lt;SPAN&gt;old_gwic_others_&amp;amp;P_YYMMDD._VAL&lt;/SPAN&gt;
set monthly.score_&amp;amp;Portofo.(keep=account_no CURR_DELQMONTH_ON_BOOK bad); &amp;gt;&amp;gt;&amp;gt; monthly.score_&lt;SPAN&gt;old_gwic_others_&amp;amp;P_YYMMDD.&lt;/SPAN&gt;

&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 14 Mar 2022 09:30:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-variable/m-p/801909#M315635</guid>
      <dc:creator>kelxxx</dc:creator>
      <dc:date>2022-03-14T09:30:16Z</dc:date>
    </item>
    <item>
      <title>Re: macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-variable/m-p/801911#M315637</link>
      <description>&lt;P&gt;Here is a very simple way to &lt;STRONG&gt;test&lt;/STRONG&gt; what it would be.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;%macro parmtest(portofo);

%put resolved value of '&amp;amp;portofo._val' is: &amp;amp;portofo._val;

%mend;

%parmtest(old_gwic_others_&amp;amp;p_yymmdd.))&lt;/PRE&gt;
&lt;P&gt;This is a very basic skill. If you don't know how to do something like this you should not be writing or trying to diagnose macros.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or run the code with OPTIONS MPRINT;&lt;/P&gt;</description>
      <pubDate>Mon, 14 Mar 2022 09:53:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-variable/m-p/801911#M315637</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-03-14T09:53:26Z</dc:date>
    </item>
    <item>
      <title>Re: macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-variable/m-p/801916#M315640</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/416388"&gt;@HeatherNewton&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;PRE&gt;%macro gen_base(Portofo,dev)
data &amp;amp;Portofo._VAL (KEEP= MOB DQ_6);
set monthly.score_&amp;amp;Portofo.(keep=account_no CURR_DELQMONTH_ON_BOOK bad);
....
run;
gen_base(old_gwic_others_&amp;amp;P_YYMMDD.,Gwic_old_others);&lt;/PRE&gt;
&lt;P&gt;Hi All I am having the above code and I am not sure what is the value of&amp;nbsp;&amp;amp;Portofo._VAL on the second line , the data line.&lt;/P&gt;
&lt;P&gt;should it be old_gwic_others_&amp;amp;P_YYMMDD.? or&amp;nbsp;old_gwic_others_&amp;amp;P_YYMMDD._VAL...&lt;/P&gt;
&lt;P&gt;and &amp;amp;dev would be "Gwic_old_others"&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;As posted, this will result in an ERROR because of the failed attempt to call the macro (missing %).&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;Once this is corrected, first the macro variable P_YYMMDD is resolved, and the completed string of old_gwic_others_&amp;lt;content of macro variable P_YYMMDD&amp;gt; is fed as parameter portofo to the macro.&lt;/P&gt;
&lt;P&gt;In the macro, you'll get&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data old_gwic_others_&amp;lt;content of macro variable P_YYMMDD&amp;gt;_VAL (KEEP= MOB DQ_6);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;set monthly.score_old_gwic_others_&amp;lt;content of macro variable P_YYMMDD&amp;gt;(keep=account_no CURR_DELQMONTH_ON_BOOK bad);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;It's all "just" simple text replacement.&lt;/P&gt;</description>
      <pubDate>Mon, 14 Mar 2022 10:25:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-variable/m-p/801916#M315640</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-03-14T10:25:59Z</dc:date>
    </item>
    <item>
      <title>Re: macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-variable/m-p/801920#M315643</link>
      <description>&lt;P&gt;There are two ways to create arguments to a macro ... with an equal sign, and without an equal sign&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Without an equal sign (this is what you did)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro gen_base(Portofo,dev);
data &amp;amp;Portofo._VAL (KEEP= MOB DQ_6);
set monthly.score_&amp;amp;Portofo.(keep=account_no CURR_DELQMONTH_ON_BOOK bad);
....
run;
%mend;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In this case the order of the variables in the call to the macro is critical&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%gen_base(old_gwic_others_&amp;amp;P_YYMMDD.,Gwic_old_others)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;means that &amp;amp;PORTOFO = old_gwic_others_&amp;amp;P_YYMMDD. and &amp;amp;DEV = Gwic_old_others&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or, if you reverse the order&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%gen_base(Gwic_old_others,old_gwic_others_&amp;amp;P_YYMMDD.)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;this means that &amp;amp;PORTOFO = Gwic_old_others and &amp;amp;DEV =&amp;nbsp;old_gwic_others_&amp;amp;P_YYMMDD.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;With equal signs, the order they are called is irrelevant&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro gen_base(Portofo=,dev=);
data &amp;amp;Portofo._VAL (KEEP= MOB DQ_6);
set monthly.score_&amp;amp;Portofo.(keep=account_no CURR_DELQMONTH_ON_BOOK bad);
....
run;
%mend;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then both of these produce the exact same results:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%gen_base(portofo = old_gwic_others_&amp;amp;P_YYMMDD., dev = Gwic_old_others)
%gen_base(dev = Gwic_old_others, portofo = old_gwic_others_&amp;amp;P_YYMMDD.)&lt;/CODE&gt;&amp;nbsp;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I strongly recommend the style where you use the equal signs, as this removes any ambiguity about which macro variable has which value. It probably doesn't matter if your macro has one or two arguments, but if you write a macro with lots of arguments, without the equal signs you will have to keep track of which argument is the 6th, and which argument is the 7th, and so on; this is easy to get wrong. If you use the equal signs, then it is always clear which macro variable is getting which value.&lt;/P&gt;</description>
      <pubDate>Mon, 14 Mar 2022 14:14:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-variable/m-p/801920#M315643</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-03-14T14:14:25Z</dc:date>
    </item>
  </channel>
</rss>

