<?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: Indirect references of macrovariables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Indirect-references-of-macrovariables/m-p/946435#M370637</link>
    <description>&lt;P&gt;Just to give you some perspective: in more than two decades of professional work with SAS, and more than a decade as data warehouse administrator and chief developer, being responsible for 1000+ SAS jobs running in production, I never had to use an indirect macro variable reference. Not once.&lt;/P&gt;
&lt;P&gt;I encountered this technique here for the first time.&lt;/P&gt;
&lt;P&gt;So don't waste too many precious brain cycles on this. There's much more important SAS stuff to learn.&lt;/P&gt;</description>
    <pubDate>Sat, 05 Oct 2024 22:15:55 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2024-10-05T22:15:55Z</dc:date>
    <item>
      <title>Indirect references of macrovariables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Indirect-references-of-macrovariables/m-p/946405#M370629</link>
      <description>&lt;P&gt;Hi everyone, please I have confusion on how an indirect references works sas macro.&lt;BR /&gt;I don't understand how this resolves to type2;&lt;/P&gt;
&lt;P&gt;%let value1 = dogs;&lt;BR /&gt;%let value2 = cats;&lt;BR /&gt;%let value3 = birds;&lt;/P&gt;
&lt;P&gt;%let type1 = value1;&lt;BR /&gt;%let type2 = value2;&lt;BR /&gt;%let type3 = value3;&lt;/P&gt;
&lt;P&gt;%let animal = type2;&lt;BR /&gt;%let final = animal;&lt;/P&gt;
&lt;P&gt;%put &amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;final;&lt;/P&gt;</description>
      <pubDate>Sat, 05 Oct 2024 09:04:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Indirect-references-of-macrovariables/m-p/946405#M370629</guid>
      <dc:creator>PrinceAde</dc:creator>
      <dc:date>2024-10-05T09:04:37Z</dc:date>
    </item>
    <item>
      <title>Re: Indirect references of macrovariables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Indirect-references-of-macrovariables/m-p/946406#M370630</link>
      <description>&lt;P&gt;If you run the macro debugging option&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options symbolgen;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;and then run your code again, you will see in the log:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt; 69         options symbolgen;
 70         %let value1 = dogs;
 71         %let value2 = cats;
 72         %let value3 = birds;
 73         
 74         %let type1 = value1;
 75         %let type2 = value2;
 76         %let type3 = value3;
 77         
 78         %let animal = type2;
 79         %let final = animal;
 80         
 81         %put &amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;final;
 SYMBOLGEN:  &amp;amp;&amp;amp; resolves to &amp;amp;.
 SYMBOLGEN:  &amp;amp;&amp;amp; resolves to &amp;amp;.
 SYMBOLGEN:  &amp;amp;&amp;amp; resolves to &amp;amp;.
 SYMBOLGEN:  &amp;amp;&amp;amp; resolves to &amp;amp;.
 SYMBOLGEN:  Macro variable FINAL resolves to animal
 SYMBOLGEN:  Macro variable ANIMAL resolves to type2
 type2
 82         &lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So double &amp;amp;&amp;amp; resolves to &amp;amp; (repeatedly), then &amp;amp;FINAL resolves to animal, then &amp;amp;ANIMAL resolves to type2.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Better yet, avoid this use of &amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp; and find other ways to accomplish the task. I never use&amp;nbsp; more than a triple ampersand.&lt;/P&gt;</description>
      <pubDate>Sat, 05 Oct 2024 09:56:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Indirect-references-of-macrovariables/m-p/946406#M370630</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-10-05T09:56:05Z</dc:date>
    </item>
    <item>
      <title>Re: Indirect references of macrovariables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Indirect-references-of-macrovariables/m-p/946407#M370631</link>
      <description>&lt;P&gt;3 iterations of resolution are done.&lt;/P&gt;
&lt;P&gt;In the first, all double ampersandsvresolve to one ampersand, so you get&lt;/P&gt;
&lt;PRE&gt;&amp;amp;&amp;amp;&amp;amp;final&lt;/PRE&gt;
&lt;P&gt;In the second, the double ampersand becomes one, and &amp;amp;final resolves to animal, so you get&lt;/P&gt;
&lt;PRE&gt;&amp;amp;animal&lt;/PRE&gt;
&lt;P&gt;In the third, &amp;amp;animal resolves to&lt;/P&gt;
&lt;PRE&gt;type2&lt;/PRE&gt;
&lt;P&gt;which is what you get.&lt;/P&gt;</description>
      <pubDate>Sat, 05 Oct 2024 09:56:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Indirect-references-of-macrovariables/m-p/946407#M370631</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2024-10-05T09:56:52Z</dc:date>
    </item>
    <item>
      <title>Re: Indirect references of macrovariables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Indirect-references-of-macrovariables/m-p/946408#M370632</link>
      <description>&lt;P&gt;Maybe running this will give you some clue:&lt;/P&gt;
&lt;PRE&gt;%put &amp;amp;final;
%put &amp;amp;&amp;amp;final;
%put &amp;amp;&amp;amp;&amp;amp;final;
%put &amp;amp;&amp;amp;&amp;amp;&amp;amp;final;
%put &amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;final;
%put &amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;final;
%put &amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;final;
%put &amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;final;
%put &amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;final;
%put &amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;final;
%put &amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;final;
%put &amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;final;
%put &amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;final;
%put &amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;final;
%put &amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;final;&lt;/PRE&gt;
&lt;P&gt;If you start writing code that requires more than &amp;amp;&amp;amp; for indirect referencing be prepared to spend a lot of time debugging as the more indirect you try to do something the number of &amp;amp; required to get to "desired" result goes up quickly.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note that multiple sets of indirect references have the same results.&lt;/P&gt;
&lt;P&gt;Look at &amp;amp;&amp;amp;&amp;amp;Final. The first &amp;amp;&amp;amp; resolve to &amp;amp; so you get &amp;amp; followed by &amp;amp;final. With &amp;amp;final=animal then you get &amp;amp;animal or&amp;nbsp; a result of type2.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2 to the nth power -1.&lt;/P&gt;
&lt;P&gt;That's how many &amp;amp; for each level (n) of indirect referencing needed. You have lots of &amp;amp;&amp;amp; resolving to &amp;amp; with more indirects.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I really hope this was an exercise as I would strongly recommend not trying to get that many indirect references to work consistently.&lt;/P&gt;</description>
      <pubDate>Sat, 05 Oct 2024 10:03:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Indirect-references-of-macrovariables/m-p/946408#M370632</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-10-05T10:03:16Z</dc:date>
    </item>
    <item>
      <title>Re: Indirect references of macrovariables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Indirect-references-of-macrovariables/m-p/946427#M370634</link>
      <description>&lt;P&gt;There should be few cases where you need more than 2 levels, but even for 2, I prefer a more explicit syntax:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let value1 = dogs;
%let value2 = cats;
%let value3 = birds;

%let type1 = value1;
%let type2 = value2;
%let type3 = value3;

%let animal = type2;
%let final = animal;

%put 1.%superq(final);
%put 2.%superq(%superq(final));
%put 3.%superq(%superq(%superq(final)));
%put 4.%superq(%superq(%superq(%superq(final))));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;DIV class="sasSource"&gt;&lt;FONT face="courier new,courier" size="3"&gt;1.animal&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;&lt;FONT face="courier new,courier" size="3"&gt;2.type2&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;&lt;FONT face="courier new,courier" size="3"&gt;3.value2&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;&lt;FONT face="courier new,courier" size="3"&gt;4.cats&lt;/FONT&gt;&lt;/DIV&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 05 Oct 2024 19:45:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Indirect-references-of-macrovariables/m-p/946427#M370634</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2024-10-05T19:45:58Z</dc:date>
    </item>
    <item>
      <title>Re: Indirect references of macrovariables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Indirect-references-of-macrovariables/m-p/946435#M370637</link>
      <description>&lt;P&gt;Just to give you some perspective: in more than two decades of professional work with SAS, and more than a decade as data warehouse administrator and chief developer, being responsible for 1000+ SAS jobs running in production, I never had to use an indirect macro variable reference. Not once.&lt;/P&gt;
&lt;P&gt;I encountered this technique here for the first time.&lt;/P&gt;
&lt;P&gt;So don't waste too many precious brain cycles on this. There's much more important SAS stuff to learn.&lt;/P&gt;</description>
      <pubDate>Sat, 05 Oct 2024 22:15:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Indirect-references-of-macrovariables/m-p/946435#M370637</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2024-10-05T22:15:55Z</dc:date>
    </item>
    <item>
      <title>Re: Indirect references of macrovariables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Indirect-references-of-macrovariables/m-p/946440#M370638</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I've seen the construct &lt;CODE class=" language-sas"&gt;&amp;amp;&amp;amp;&amp;amp;var&amp;amp;i&lt;/CODE&gt; used on regularly. I'm surprised you haven't.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 06 Oct 2024 08:34:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Indirect-references-of-macrovariables/m-p/946440#M370638</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2024-10-06T08:34:37Z</dc:date>
    </item>
    <item>
      <title>Re: Indirect references of macrovariables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Indirect-references-of-macrovariables/m-p/946441#M370639</link>
      <description>&lt;P&gt;Probably because I always keep data in datasets, which reduces the need for macro arrays.&lt;/P&gt;
&lt;P&gt;Anyway, just deciphering a mass of ampersands takes much too much time when maintaining programs, that's why it's so impractical.&lt;/P&gt;</description>
      <pubDate>Sun, 06 Oct 2024 11:59:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Indirect-references-of-macrovariables/m-p/946441#M370639</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2024-10-06T11:59:34Z</dc:date>
    </item>
    <item>
      <title>Re: Indirect references of macrovariables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Indirect-references-of-macrovariables/m-p/946444#M370640</link>
      <description>&lt;P&gt;I think the macroArray package can make work with macro variable arrays (i.e. &amp;amp;&amp;amp;prefix&amp;amp;sufix constructs) easier.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Article describing it:&amp;nbsp;&lt;STRONG&gt;&lt;A href="https://www.lexjansen.com/pharmasug/2024/AP/PharmaSUG-2024-AP-108.pdf" target="_blank"&gt;https://www.lexjansen.com/pharmasug/2024/AP/PharmaSUG-2024-AP-108.pdf&lt;/A&gt;&lt;/STRONG&gt;&amp;nbsp;has been published in &lt;A href="https://www.lexjansen.com/cgi-bin/xsl_transform.php?x=sap&amp;amp;s=PHARMASUG_s&amp;amp;c=PHARMASUG" target="_self"&gt;PharmaSUG 2024 proceedings&lt;/A&gt;&amp;nbsp; and re-published in &lt;A href="https://www.lexjansen.com/cgi-bin/xsl_transform.php?x=wuss2024#WUSS2024-ll054" target="_self"&gt;WUSS 2024 proceedings.&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The package itself is located here:&amp;nbsp;&lt;A href="https://github.com/SASPAC/macroarray" target="_blank"&gt;https://github.com/SASPAC/macroarray&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;All the best&lt;/P&gt;
&lt;P&gt;Bart&lt;/P&gt;</description>
      <pubDate>Sun, 06 Oct 2024 15:03:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Indirect-references-of-macrovariables/m-p/946444#M370640</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2024-10-06T15:03:39Z</dc:date>
    </item>
  </channel>
</rss>

