<?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 contain another macro variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Macro-variable-contain-another-macro-variable/m-p/720369#M223154</link>
    <description>&lt;P&gt;Try this:&lt;/P&gt;
&lt;PRE&gt;%let n1=aa;
%let n2=bb;

%Macro check(count=);
	%IF &amp;amp;&amp;amp;n&amp;amp;count.=aa %then %do;
			%put code working;
	%end;
%mend;

%check(count=1); 
%check(count=2); &lt;/PRE&gt;
&lt;P&gt;The &amp;amp;&amp;amp;var&amp;amp;othervar is called "indirect reference". In effect the the first 2 &amp;amp;&amp;amp; resolve to one &amp;amp; and holds that while the other bits&amp;nbsp; var&amp;amp;othervar resolve, then use &amp;amp;&amp;lt;resolved&amp;gt;.&lt;/P&gt;
&lt;P&gt;Note that your comparsion with 'aa' was NEVER going to work without providing quotes in the values as the macro language works differently than the data step. EVERYTHING in the macro language is text so quotes are seldom needed unless the value has to resolve with a quote (and be prepared for lots of headaches getting them to work).&lt;/P&gt;</description>
    <pubDate>Fri, 19 Feb 2021 00:54:50 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2021-02-19T00:54:50Z</dc:date>
    <item>
      <title>Macro variable contain another macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-variable-contain-another-macro-variable/m-p/720362#M223151</link>
      <description>&lt;P&gt;Hi Everyone,&lt;/P&gt;
&lt;P&gt;I need to perform a check of macro variable (&amp;amp;n1 and &amp;amp;n2) value inside %DO loop.&lt;/P&gt;
&lt;P&gt;So with count=1, the Macro will not return anything since &amp;amp;n&amp;amp;count turns to &amp;amp;n1 which has value of 'aa'&lt;/P&gt;
&lt;P&gt;With count=2, Macro will run.&lt;/P&gt;
&lt;P&gt;Can you please help to fix that IF statement below?&lt;/P&gt;
&lt;P&gt;Thank you,&lt;/P&gt;
&lt;P&gt;HHCFX&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
%let n1=aa;
%let n2=bb;

%Macro check(count=);
	%IF &amp;amp;n&amp;amp;count!='aa' %then %do;
			%put code working;
	%end;
%mend;

%check(count=1); 
%check(count=2); 
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 18 Feb 2021 23:31:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-variable-contain-another-macro-variable/m-p/720362#M223151</guid>
      <dc:creator>hhchenfx</dc:creator>
      <dc:date>2021-02-18T23:31:07Z</dc:date>
    </item>
    <item>
      <title>Re: Macro variable contain another macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-variable-contain-another-macro-variable/m-p/720369#M223154</link>
      <description>&lt;P&gt;Try this:&lt;/P&gt;
&lt;PRE&gt;%let n1=aa;
%let n2=bb;

%Macro check(count=);
	%IF &amp;amp;&amp;amp;n&amp;amp;count.=aa %then %do;
			%put code working;
	%end;
%mend;

%check(count=1); 
%check(count=2); &lt;/PRE&gt;
&lt;P&gt;The &amp;amp;&amp;amp;var&amp;amp;othervar is called "indirect reference". In effect the the first 2 &amp;amp;&amp;amp; resolve to one &amp;amp; and holds that while the other bits&amp;nbsp; var&amp;amp;othervar resolve, then use &amp;amp;&amp;lt;resolved&amp;gt;.&lt;/P&gt;
&lt;P&gt;Note that your comparsion with 'aa' was NEVER going to work without providing quotes in the values as the macro language works differently than the data step. EVERYTHING in the macro language is text so quotes are seldom needed unless the value has to resolve with a quote (and be prepared for lots of headaches getting them to work).&lt;/P&gt;</description>
      <pubDate>Fri, 19 Feb 2021 00:54:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-variable-contain-another-macro-variable/m-p/720369#M223154</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-02-19T00:54:50Z</dc:date>
    </item>
    <item>
      <title>Re: Macro variable contain another macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-variable-contain-another-macro-variable/m-p/720371#M223156</link>
      <description>&lt;P&gt;Thank you so much!&lt;/P&gt;
&lt;P&gt;HHC&lt;/P&gt;</description>
      <pubDate>Fri, 19 Feb 2021 01:12:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-variable-contain-another-macro-variable/m-p/720371#M223156</guid>
      <dc:creator>hhchenfx</dc:creator>
      <dc:date>2021-02-19T01:12:27Z</dc:date>
    </item>
  </channel>
</rss>

