<?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 a let statement not resolving all the way in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/macro-variable-in-a-let-statement-not-resolving-all-the-way/m-p/367443#M87465</link>
    <description>&lt;P&gt;thank you very much, I Stopped at 4 &amp;amp;.&lt;/P&gt;</description>
    <pubDate>Thu, 15 Jun 2017 17:06:17 GMT</pubDate>
    <dc:creator>BillBaker_cd3</dc:creator>
    <dc:date>2017-06-15T17:06:17Z</dc:date>
    <item>
      <title>macro variable in a let statement not resolving all the way</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-variable-in-a-let-statement-not-resolving-all-the-way/m-p/367435#M87462</link>
      <description>&lt;P&gt;I the following code I am trying to create a dynamic variable name and use it later in the code, but it isn't fully resolving.&amp;nbsp; please see the last few lines.&amp;nbsp; I would like the put statement macro variable &lt;FONT face="Courier New" size="2"&gt;&amp;amp;&amp;amp;mem&amp;amp;i.._rcols&lt;/FONT&gt; to output the same info that is in &amp;amp;xx.&amp;nbsp; I have also tried a data _null_&amp;nbsp; with a call symput to create the varialbe.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;%macro&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; &lt;STRONG&gt;&lt;I&gt;a&lt;/I&gt;&lt;/STRONG&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;Data _null_;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;call symput(&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;"mem1"&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;,&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;"ae"&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;call symput(&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;"mem1vartotal"&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;,&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;"4"&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;call symput(&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;"mem2"&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;,&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;"cm"&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;call symput(&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;"mem2vartotal"&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;,&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;"3"&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%do&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; i = &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%to&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;2&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; x = 0;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%do&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; v = &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%to&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; &amp;amp;&amp;amp;mem&amp;amp;i.vartotal;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; x = &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%eval&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;(&amp;amp;x + 1);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%end&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; &amp;amp;&amp;amp;mem&amp;amp;i.._rcols = &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%str&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;();&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; xx=&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%str&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;(); &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%do&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; k=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%to&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; &amp;amp;x;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; xx = &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%str&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;(&amp;amp;xx, _&amp;amp;k);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%end&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; &amp;amp;&amp;amp;mem&amp;amp;i.._rcols = &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%str&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;(&amp;amp;xx);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%put&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; &amp;amp;&amp;amp;mem&amp;amp;i &amp;amp;&amp;amp;mem&amp;amp;i.._rcols &amp;amp;xx ;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%end&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;%mend&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; a;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;%&lt;STRONG&gt;&lt;I&gt;a&lt;/I&gt;&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Jun 2017 16:47:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-variable-in-a-let-statement-not-resolving-all-the-way/m-p/367435#M87462</guid>
      <dc:creator>BillBaker_cd3</dc:creator>
      <dc:date>2017-06-15T16:47:00Z</dc:date>
    </item>
    <item>
      <title>Re: macro variable in a let statement not resolving all the way</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-variable-in-a-let-statement-not-resolving-all-the-way/m-p/367440#M87464</link>
      <description>It's a little terrifying, but looks like:&lt;BR /&gt;%put &amp;amp;&amp;amp;mem&amp;amp;i &amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;mem&amp;amp;i.._rcols &amp;amp;xx ;&lt;BR /&gt;works</description>
      <pubDate>Thu, 15 Jun 2017 16:55:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-variable-in-a-let-statement-not-resolving-all-the-way/m-p/367440#M87464</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2017-06-15T16:55:19Z</dc:date>
    </item>
    <item>
      <title>Re: macro variable in a let statement not resolving all the way</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-variable-in-a-let-statement-not-resolving-all-the-way/m-p/367443#M87465</link>
      <description>&lt;P&gt;thank you very much, I Stopped at 4 &amp;amp;.&lt;/P&gt;</description>
      <pubDate>Thu, 15 Jun 2017 17:06:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-variable-in-a-let-statement-not-resolving-all-the-way/m-p/367443#M87465</guid>
      <dc:creator>BillBaker_cd3</dc:creator>
      <dc:date>2017-06-15T17:06:17Z</dc:date>
    </item>
    <item>
      <title>Re: macro variable in a let statement not resolving all the way</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-variable-in-a-let-statement-not-resolving-all-the-way/m-p/367481#M87488</link>
      <description>&lt;P&gt;It is MUCH easier to store the generated macro variable name into another macro variable and then use three &amp;amp; to evaluate the macro variable that it names.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro a;
%local i k name;
%do i = 1 %to 2;
    %let name=&amp;amp;&amp;amp;mem&amp;amp;i.._rcols;
    %local &amp;amp;name ;
    %let &amp;amp;name=;
    %do k=1 %to &amp;amp;&amp;amp;mem&amp;amp;i.vartotal;
        %let &amp;amp;name = &amp;amp;&amp;amp;&amp;amp;name, _&amp;amp;k;
    %end;
    %put &amp;amp;=i|&amp;amp;&amp;amp;mem&amp;amp;i|&amp;amp;=name|&amp;amp;&amp;amp;&amp;amp;name| ;
%end;
%put _local_;
%mend a;

data _null_;
call symput("mem1","ae");
call symput("mem1vartotal","4");
call symput("mem2","cm");
call symput("mem2vartotal","3");
run;

%a;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Results&lt;/P&gt;
&lt;PRE&gt;I=1|ae|NAME=ae_rcols|, _1, _2, _3, _4|
I=2|cm|NAME=cm_rcols|, _1, _2, _3|
A AE_RCOLS , _1, _2, _3, _4
A CM_RCOLS , _1, _2, _3
A I 3
A K 4
A NAME cm_rcols&lt;/PRE&gt;</description>
      <pubDate>Thu, 15 Jun 2017 19:37:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-variable-in-a-let-statement-not-resolving-all-the-way/m-p/367481#M87488</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-06-15T19:37:35Z</dc:date>
    </item>
  </channel>
</rss>

