<?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 Variables with Multiple Ampersands in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Macro-Variables-with-Multiple-Ampersands/m-p/409580#M100062</link>
    <description>&lt;P&gt;Sorry, I read the problem wrong.&amp;nbsp; Is it that your original code is correct, except for switching the "TN" vs. "NT" in the %LET statement?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;********************&lt;/P&gt;
&lt;P&gt;EDITED:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Besides that, I think you need to use 6 ampersands.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 01 Nov 2017 18:46:06 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2017-11-01T18:46:06Z</dc:date>
    <item>
      <title>Macro Variables with Multiple Ampersands</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Variables-with-Multiple-Ampersands/m-p/409573#M100059</link>
      <description>&lt;P&gt;Okay.&amp;nbsp; This is getting on my nerves.&amp;nbsp; Just when I think I&amp;nbsp;know how to access macro variables with multiple ampersands, something goes wrong.&amp;nbsp; Can someone correct my code so I can display the values 7 and 624?&amp;nbsp; I have tried all kinds of combinations of ampersands and periods, but the closest I can get it to display "BRON_BRON_R1_TERM_CNT" and "CM_TERM_CNT" instead of "7" and "624".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let dsname1=BRON_BRON_R1;
%let dsname2=CM;

%let BRON_BRON_R1_TERM_CNT=7;
%let CM_TERM_CTN=624;


%macro loop;
	%do i=1 %to 2;
		%put &amp;amp;&amp;amp;&amp;amp;&amp;amp;dsname&amp;amp;i.._TERM_CNT;
	%end;
%mend loop;

%loop;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 01 Nov 2017 18:20:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Variables-with-Multiple-Ampersands/m-p/409573#M100059</guid>
      <dc:creator>djbateman</dc:creator>
      <dc:date>2017-11-01T18:20:48Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Variables with Multiple Ampersands</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Variables-with-Multiple-Ampersands/m-p/409575#M100060</link>
      <description>&lt;P&gt;If you cut down the number of &amp;amp; from 4 down to 2, you should be fine.&lt;/P&gt;</description>
      <pubDate>Wed, 01 Nov 2017 18:32:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Variables-with-Multiple-Ampersands/m-p/409575#M100060</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-11-01T18:32:17Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Variables with Multiple Ampersands</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Variables-with-Multiple-Ampersands/m-p/409578#M100061</link>
      <description>&lt;P&gt;That doesn't work for me.&amp;nbsp; I get the values "BRON_BRON_R1_TERM_CNT" and "CM_TERM_CNT" instead of "7" and "624".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Using &amp;amp;&amp;amp; converts &amp;amp;&amp;amp;dsname&amp;amp;i. to&amp;nbsp;&amp;amp;dsname1, which converts to BRON_BRON_R1, so I am left with BRON_BRON_R1_TERM_CNT.&amp;nbsp; I now need SAS to recognize &amp;amp;&lt;SPAN&gt;BRON_BRON_R1_TERM_CNT, which is why I added the extra &amp;amp;&amp;amp; in front.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;If i use&amp;nbsp;&amp;amp;&amp;amp;dsname&amp;amp;i.._TERM_CNT, I get:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;MLOGIC(LOOP):  Beginning execution.
MLOGIC(LOOP):  %DO loop beginning; index variable I; start value is 1; stop value is 2; by value is
      1.
MLOGIC(LOOP):  %PUT &amp;amp;&amp;amp;dsname&amp;amp;i.._TERM_CNT
SYMBOLGEN:  &amp;amp;&amp;amp; resolves to &amp;amp;.
SYMBOLGEN:  Macro variable I resolves to 1
SYMBOLGEN:  Macro variable DSNAME1 resolves to BRON_BRON_R1
BRON_BRON_R1_TERM_CNT
MLOGIC(LOOP):  %DO loop index variable I is now 2; loop will iterate again.
MLOGIC(LOOP):  %PUT &amp;amp;&amp;amp;dsname&amp;amp;i.._TERM_CNT
SYMBOLGEN:  &amp;amp;&amp;amp; resolves to &amp;amp;.
SYMBOLGEN:  Macro variable I resolves to 2
SYMBOLGEN:  Macro variable DSNAME2 resolves to CM
CM_TERM_CNT
MLOGIC(LOOP):  %DO loop index variable I is now 3; loop will not iterate again.
MLOGIC(LOOP):  Ending execution.

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;If I use&amp;nbsp;&lt;SPAN&gt;&amp;amp;&amp;amp;&amp;amp;&amp;amp;dsname&amp;amp;i.._TERM_CNT, I get the exact same thing:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;MLOGIC(LOOP):  Beginning execution.
MLOGIC(LOOP):  %DO loop beginning; index variable I; start value is 1; stop value is 2; by value is
      1.
MLOGIC(LOOP):  %PUT &amp;amp;&amp;amp;&amp;amp;&amp;amp;dsname&amp;amp;i.._TERM_CNT
SYMBOLGEN:  &amp;amp;&amp;amp; resolves to &amp;amp;.
SYMBOLGEN:  &amp;amp;&amp;amp; resolves to &amp;amp;.
SYMBOLGEN:  Macro variable I resolves to 1
SYMBOLGEN:  &amp;amp;&amp;amp; resolves to &amp;amp;.
SYMBOLGEN:  Macro variable DSNAME1 resolves to BRON_BRON_R1
BRON_BRON_R1_TERM_CNT
MLOGIC(LOOP):  %DO loop index variable I is now 2; loop will iterate again.
MLOGIC(LOOP):  %PUT &amp;amp;&amp;amp;&amp;amp;&amp;amp;dsname&amp;amp;i.._TERM_CNT
SYMBOLGEN:  &amp;amp;&amp;amp; resolves to &amp;amp;.
SYMBOLGEN:  &amp;amp;&amp;amp; resolves to &amp;amp;.
SYMBOLGEN:  Macro variable I resolves to 2
SYMBOLGEN:  &amp;amp;&amp;amp; resolves to &amp;amp;.
SYMBOLGEN:  Macro variable DSNAME2 resolves to CM
CM_TERM_CNT
MLOGIC(LOOP):  %DO loop index variable I is now 3; loop will not iterate again.
MLOGIC(LOOP):  Ending execution.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;SPAN&gt;BUT WHY!!!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 01 Nov 2017 18:37:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Variables-with-Multiple-Ampersands/m-p/409578#M100061</guid>
      <dc:creator>djbateman</dc:creator>
      <dc:date>2017-11-01T18:37:04Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Variables with Multiple Ampersands</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Variables-with-Multiple-Ampersands/m-p/409580#M100062</link>
      <description>&lt;P&gt;Sorry, I read the problem wrong.&amp;nbsp; Is it that your original code is correct, except for switching the "TN" vs. "NT" in the %LET statement?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;********************&lt;/P&gt;
&lt;P&gt;EDITED:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Besides that, I think you need to use 6 ampersands.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 01 Nov 2017 18:46:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Variables-with-Multiple-Ampersands/m-p/409580#M100062</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-11-01T18:46:06Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Variables with Multiple Ampersands</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Variables-with-Multiple-Ampersands/m-p/409582#M100063</link>
      <description>&lt;P&gt;Oh, good catch on the misspelling.&amp;nbsp; But that obviously wasn't the problem since BRON_BRON_R1_TERM_CNT wasn't misspelled.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Still, I tried the 6 ampersands, and that seems to have done it.&amp;nbsp; I can never tell how many to use.&amp;nbsp; I've never needed more than 4, so I never went beyond that.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you so much!&lt;/P&gt;</description>
      <pubDate>Wed, 01 Nov 2017 18:54:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Variables-with-Multiple-Ampersands/m-p/409582#M100063</guid>
      <dc:creator>djbateman</dc:creator>
      <dc:date>2017-11-01T18:54:18Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Variables with Multiple Ampersands</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Variables-with-Multiple-Ampersands/m-p/409594#M100068</link>
      <description>&lt;P&gt;You could make your life a whole lot simpler if you just didn't have to have _TERM_CNT at the end of the macro variable names. You could even put TERM_CNT_ at the beginning to achieve this simplicity.&lt;/P&gt;</description>
      <pubDate>Wed, 01 Nov 2017 19:22:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Variables-with-Multiple-Ampersands/m-p/409594#M100068</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2017-11-01T19:22:24Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Variables with Multiple Ampersands</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Variables-with-Multiple-Ampersands/m-p/409686#M100101</link>
      <description>&lt;P&gt;My breaking point was 5. I basically changed my approach to macros that night.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When macros get really complex, consider spooling the problem out and then including it back in.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data _null_ ;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;file myFile;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;do i = 1 to 3 ;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; put 'test_' i ;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;end;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%include myFile;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Simplifies debugging TREMENDOUSLY. There are other ways than that too: just get creative...but readable.&lt;/P&gt;</description>
      <pubDate>Thu, 02 Nov 2017 00:48:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Variables-with-Multiple-Ampersands/m-p/409686#M100101</guid>
      <dc:creator>AlanC</dc:creator>
      <dc:date>2017-11-02T00:48:26Z</dc:date>
    </item>
  </channel>
</rss>

