<?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: How to scan a macro variable and use the result as a variable name in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-scan-a-macro-variable-and-use-the-result-as-a-variable/m-p/78776#M17029</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;You need another ARRAY.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;array want(*) $ &amp;amp;varlist.;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt; array have $ &amp;amp;vars ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp; ...&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'courier new', courier; font-size: 10pt; line-height: 1.5em;"&gt;want((_n_-1)*4+_i)=have(_i) ;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 18 Jan 2013 02:56:38 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2013-01-18T02:56:38Z</dc:date>
    <item>
      <title>How to scan a macro variable and use the result as a variable name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-scan-a-macro-variable-and-use-the-result-as-a-variable/m-p/78775#M17028</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The following, except for the fourth line from the bottom of the code, does what I want.&amp;nbsp; However, in the section:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; do _i=1 to 4;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; want((_n_-1)*4+_i)=scan("&amp;amp;vars.",_i);&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'd like to assign the values of var1, var2, var3 and var4&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What do I have to change/add/modify in order to obtain that result?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;TIA,&lt;/P&gt;&lt;P&gt;Art&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data have (drop=months);&lt;/P&gt;&lt;P&gt;&amp;nbsp; format id best32.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; input date (ind1-ind4) ($) ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; informat date date9.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; format date yymon7.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; array other_variable(2);&lt;/P&gt;&lt;P&gt;&amp;nbsp; do id=1 to 2;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; other_variable(id)=id;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; other_variable1=1;&lt;/P&gt;&lt;P&gt;&amp;nbsp; other_variable2=2;&lt;/P&gt;&lt;P&gt;&amp;nbsp; do id=1 to 10;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; date="01dec2010"d;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; do months=1 to 12;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; date=intnx('month',date,1);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if not(months eq 9 and mod(id,2)) then output;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; cards;&lt;/P&gt;&lt;P&gt;01dec2010 A B C D&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;%let filein=have;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;%let by_variable=id;&lt;/P&gt;&lt;P&gt;%let vars=ind1 ind2 ind3 ind4;&lt;/P&gt;&lt;P&gt;%let numvars=4;&lt;/P&gt;&lt;P&gt;%let id_label=date;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql noprint;&lt;/P&gt;&lt;P&gt;&amp;nbsp; select distinct 'ind1_'||put(date,yymon7.)||&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ' ind2_'||put(date,yymon7.)||&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ' ind3_'||put(date,yymon7.)||&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ' ind4_'||put(date,yymon7.),&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; date&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; into :varlist separated by " ",&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; :junk&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; from &amp;amp;filein. (obs=1000) /*must be big enough to capture all months*/&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; order by &amp;amp;id_label.&lt;/P&gt;&lt;P&gt;&amp;nbsp; ;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set &amp;amp;filein.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; by &amp;amp;by_variable.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; array want(*) $ &amp;amp;varlist.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; retain want;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if first.id then call missing(of want(*));&lt;/P&gt;&lt;P&gt;&amp;nbsp; _n_=month(date);&lt;/P&gt;&lt;P&gt;&amp;nbsp; do _i=1 to 4;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; want((_n_-1)*4+_i)=scan("&amp;amp;vars.",_i);&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; drop &amp;amp;id_label. _: &amp;amp;vars.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if last.&amp;amp;by_variable. then output;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 18 Jan 2013 01:13:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-scan-a-macro-variable-and-use-the-result-as-a-variable/m-p/78775#M17028</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2013-01-18T01:13:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to scan a macro variable and use the result as a variable name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-scan-a-macro-variable-and-use-the-result-as-a-variable/m-p/78776#M17029</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;You need another ARRAY.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;array want(*) $ &amp;amp;varlist.;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt; array have $ &amp;amp;vars ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp; ...&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'courier new', courier; font-size: 10pt; line-height: 1.5em;"&gt;want((_n_-1)*4+_i)=have(_i) ;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 18 Jan 2013 02:56:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-scan-a-macro-variable-and-use-the-result-as-a-variable/m-p/78776#M17029</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2013-01-18T02:56:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to scan a macro variable and use the result as a variable name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-scan-a-macro-variable-and-use-the-result-as-a-variable/m-p/78777#M17030</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Tom,&amp;nbsp; I'll come back and mark your response as "correct" rather than just "helpful" if no one can come up with a way of doing what I'd really like to do.&amp;nbsp; However, using an array definitely solved the problem.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 18 Jan 2013 04:00:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-scan-a-macro-variable-and-use-the-result-as-a-variable/m-p/78777#M17030</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2013-01-18T04:00:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to scan a macro variable and use the result as a variable name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-scan-a-macro-variable-and-use-the-result-as-a-variable/m-p/78778#M17031</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Use VVALUEX? Note that this will actually get the formatted value of the variable. Of course this means that you &amp;amp;VARS list can include numeric and character variables.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier; background-color: #ffffff;"&gt; want((_n_-1)*4+_i)=vvaluex(scan("&amp;amp;vars.",_i));&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 18 Jan 2013 05:59:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-scan-a-macro-variable-and-use-the-result-as-a-variable/m-p/78778#M17031</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2013-01-18T05:59:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to scan a macro variable and use the result as a variable name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-scan-a-macro-variable-and-use-the-result-as-a-variable/m-p/78779#M17032</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A __default_attr="2431" __jive_macro_name="user" class="jive_macro jive_macro_user" data-objecttype="3" href="https://communities.sas.com/"&gt;&lt;/A&gt;: That was definitely what I was looking for and, yes, it would allow combining character and numeric variables if I changed the program so that it wasn't forcing all of the results into a single array.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, I'm not going to use it, after all, as it came with a high price.&amp;nbsp; It doubled the cpu time required for the overall process.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 18 Jan 2013 14:35:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-scan-a-macro-variable-and-use-the-result-as-a-variable/m-p/78779#M17032</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2013-01-18T14:35:28Z</dc:date>
    </item>
  </channel>
</rss>

