<?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: Call a series of macro variables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Call-a-series-of-macro-variables/m-p/472508#M121164</link>
    <description>&lt;P&gt;Depends on the exact problem, the simplest method is just to merge the X row onto any data where you want to use it.&lt;/P&gt;</description>
    <pubDate>Fri, 22 Jun 2018 14:58:51 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2018-06-22T14:58:51Z</dc:date>
    <item>
      <title>Call a series of macro variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Call-a-series-of-macro-variables/m-p/472475#M121152</link>
      <description>&lt;P&gt;Hi folks,&lt;/P&gt;&lt;P&gt;I have some problem to call a series of macro variables from a table.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Say I have a table stored some values, namely:&lt;/P&gt;&lt;P&gt;Table1&lt;/P&gt;&lt;P&gt;x1&amp;nbsp; &amp;nbsp;x2&amp;nbsp; &amp;nbsp; x3&lt;/P&gt;&lt;P&gt;5&amp;nbsp; &amp;nbsp; &amp;nbsp; 7&amp;nbsp; &amp;nbsp; &amp;nbsp; 6&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to use the call symputx function to call all the macro variables at the same time. Basically I am wrting a code like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Data storedvalue;&lt;/P&gt;&lt;P&gt;Table1;&lt;/P&gt;&lt;P&gt;do i=1 to 3;&lt;/P&gt;&lt;P&gt;call symputx("macroi",xi);&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, it's not working since i is not evaluated. Any idea on this question?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 22 Jun 2018 13:33:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Call-a-series-of-macro-variables/m-p/472475#M121152</guid>
      <dc:creator>liyongkai800</dc:creator>
      <dc:date>2018-06-22T13:33:08Z</dc:date>
    </item>
    <item>
      <title>Re: Call a series of macro variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Call-a-series-of-macro-variables/m-p/472481#M121153</link>
      <description>&lt;PRE&gt;data storedvalue;
  set table1;
  array x{3};
  do i=1 to 3;
    call symputx(cats('macro',put(i,best.)),x{i});
  end;
run;&lt;/PRE&gt;
&lt;P&gt;As you can see you missed a few points, a set statement, an array statement.&amp;nbsp; Plus you need to create&amp;nbsp; string for the macro name, and refer to the array for the value.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would also advise you to consider why you want to create lots of macro variables, there is likely a better method.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 22 Jun 2018 13:41:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Call-a-series-of-macro-variables/m-p/472481#M121153</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-06-22T13:41:43Z</dc:date>
    </item>
    <item>
      <title>Re: Call a series of macro variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Call-a-series-of-macro-variables/m-p/472485#M121155</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I came up with an almost identical solution as &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/45151"&gt;@RW9&lt;/a&gt;:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
   input x1 x2 x3;
   datalines;
5      7      6
;

%let macro1=;
%let macro2=;
%let macro3=;

data _null_;
   set have;

   array x(3);

   do i = 1 to 3;
      call symputx(cats('macro',i),x[i]);
   end;
run;

%put macro1=&amp;amp;macro1;
%put macro2=&amp;amp;macro2;
%put macro3=&amp;amp;macro3;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;From the documentation, an advantage of using the &lt;FONT face="courier new,courier"&gt;cats()&lt;/FONT&gt; function is:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;The CATS function removes leading and trailing blanks from numeric arguments after it formats the numeric value with the BEST&lt;SPAN class="xis-userSuppliedValue"&gt;w&lt;/SPAN&gt;. format.&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For more details see:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/lefunctionsref/63354/HTML/default/viewer.htm#n1e21rr6al5m2nn19r1fat5qxwrt.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/lefunctionsref/63354/HTML/default/viewer.htm#n1e21rr6al5m2nn19r1fat5qxwrt.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Amir.&lt;/P&gt;</description>
      <pubDate>Fri, 22 Jun 2018 14:02:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Call-a-series-of-macro-variables/m-p/472485#M121155</guid>
      <dc:creator>Amir</dc:creator>
      <dc:date>2018-06-22T14:02:16Z</dc:date>
    </item>
    <item>
      <title>Re: Call a series of macro variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Call-a-series-of-macro-variables/m-p/472503#M121162</link>
      <description>Thanks a lot. I want to use those values in the late data step, but I don't know how to call them, that's why I want to store them as macro variables. Is it possible that I have some statement like:&lt;BR /&gt;Data want;&lt;BR /&gt;set whatever;&lt;BR /&gt;/** call the value from stored value**/;&lt;BR /&gt;/**calculation here**/;&lt;BR /&gt;run;&lt;BR /&gt;</description>
      <pubDate>Fri, 22 Jun 2018 14:46:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Call-a-series-of-macro-variables/m-p/472503#M121162</guid>
      <dc:creator>liyongkai800</dc:creator>
      <dc:date>2018-06-22T14:46:04Z</dc:date>
    </item>
    <item>
      <title>Re: Call a series of macro variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Call-a-series-of-macro-variables/m-p/472508#M121164</link>
      <description>&lt;P&gt;Depends on the exact problem, the simplest method is just to merge the X row onto any data where you want to use it.&lt;/P&gt;</description>
      <pubDate>Fri, 22 Jun 2018 14:58:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Call-a-series-of-macro-variables/m-p/472508#M121164</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-06-22T14:58:51Z</dc:date>
    </item>
  </channel>
</rss>

