<?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: Trouble resolving macro variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Trouble-resolving-macro-variable/m-p/63217#M13747</link>
    <description>Best to explain in your words (and illustrate both INPUT and desired OUTPUT sides) what it is that you want to accomplish. &lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
    <pubDate>Tue, 11 Aug 2009 14:45:39 GMT</pubDate>
    <dc:creator>sbb</dc:creator>
    <dc:date>2009-08-11T14:45:39Z</dc:date>
    <item>
      <title>Trouble resolving macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trouble-resolving-macro-variable/m-p/63216#M13746</link>
      <description>Any suggestions on how to get 'hs' to resolve correctly?  &lt;BR /&gt;
data test;&lt;BR /&gt;
input a1_1 a2_1 a3_1;&lt;BR /&gt;
cards;&lt;BR /&gt;
1 2 3&lt;BR /&gt;
3 4 5&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
%macro symps;&lt;BR /&gt;
&lt;BR /&gt;
data test2 ( keep = a1 );&lt;BR /&gt;
  set test; &lt;BR /&gt;
  array a1_(1) a1_1;&lt;BR /&gt;
  &lt;BR /&gt;
  call symput( 'hs' , trim( left( _n_ ) ) );&lt;BR /&gt;
  a1 = a&amp;amp;hs._1;  /*i want this to resolve to something like a1=a2_1 */&lt;BR /&gt;
  put _all_;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
%mend symps;&lt;BR /&gt;
&lt;BR /&gt;
%symps;&lt;BR /&gt;
proc print data = test2;&lt;BR /&gt;
run;</description>
      <pubDate>Tue, 11 Aug 2009 14:41:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trouble-resolving-macro-variable/m-p/63216#M13746</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-08-11T14:41:42Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble resolving macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trouble-resolving-macro-variable/m-p/63217#M13747</link>
      <description>Best to explain in your words (and illustrate both INPUT and desired OUTPUT sides) what it is that you want to accomplish. &lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Tue, 11 Aug 2009 14:45:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trouble-resolving-macro-variable/m-p/63217#M13747</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2009-08-11T14:45:39Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble resolving macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trouble-resolving-macro-variable/m-p/63218#M13748</link>
      <description>Sure.  I want to assign the value contained in a3_1 to a new variable.  But i need to reference an array that has the form aN_(index), where N = 1, 2, ... 10.  The 'N' is determined in a prior loop in the same data step.  In this example, I want a1 = 1 where _n_=1, a1 = 4 when _n_=2.&lt;BR /&gt;
&lt;BR /&gt;
Does that help?  My example was an attempt to simplify my current program.  When i run this code, I get the warning "...hs not resolved." and error: "data step component object failure".

Message was edited by: AndyC</description>
      <pubDate>Tue, 11 Aug 2009 14:58:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trouble-resolving-macro-variable/m-p/63218#M13748</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-08-11T14:58:29Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble resolving macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trouble-resolving-macro-variable/m-p/63219#M13749</link>
      <description>The macro variable 'hs' will be resolved before the symput is executed, so this won't work.&lt;BR /&gt;
&lt;BR /&gt;
You could accomplish the intended result (*) by putting a1_1 a2_1 a3_1 into a data step array (say MYARRAY), and then you'd  have something like:&lt;BR /&gt;
&lt;BR /&gt;
  a1 = myarray(_n_);&lt;BR /&gt;
&lt;BR /&gt;
(*) But I'm not convinced I understand what you are really trying to accomplish.</description>
      <pubDate>Tue, 11 Aug 2009 15:04:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trouble-resolving-macro-variable/m-p/63219#M13749</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-08-11T15:04:22Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble resolving macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trouble-resolving-macro-variable/m-p/63220#M13750</link>
      <description>%macro symps;&lt;BR /&gt;
&lt;BR /&gt;
data test2 ( keep = a1 );&lt;BR /&gt;
  set test; &lt;BR /&gt;
  array myarray(3) a1_1 a2_1 a3_1;&lt;BR /&gt;
  a = myarray(_n_);&lt;BR /&gt;
 &lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
%mend symps;&lt;BR /&gt;
Thanks that works in my example.  Hope it will work in the context of my larger program.  Andy</description>
      <pubDate>Tue, 11 Aug 2009 15:26:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trouble-resolving-macro-variable/m-p/63220#M13750</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-08-11T15:26:24Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble resolving macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trouble-resolving-macro-variable/m-p/63221#M13751</link>
      <description>Suggest you exercise the DATA step - recommend adding the line:&lt;BR /&gt;
&lt;BR /&gt;
PUTLOG _ALL_;&lt;BR /&gt;
&lt;BR /&gt;
so you can see the SAS variables at any given point in the DATA step portion of the program.&lt;BR /&gt;
&lt;BR /&gt;
Also, your SAS log will likely have some tell-tale diagnostic NOTE, WARNING or ERROR messages for you to review and possibly debug, for example - given your code, I expect you will have a note:&lt;BR /&gt;
&lt;BR /&gt;
NOTE: VARIABLE A IS UNINITIALIZED&lt;BR /&gt;
&lt;BR /&gt;
and you will see from the PUTLOG that the named variable does not have an assigned value -- because of your assignment line.&lt;BR /&gt;
&lt;BR /&gt;
And given that you likely want an observation for each A1 value, you will need to code a DO / END loop to bump through the array, and issue an OUTPUT statement within the DO loop.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Tue, 11 Aug 2009 16:19:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trouble-resolving-macro-variable/m-p/63221#M13751</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2009-08-11T16:19:04Z</dc:date>
    </item>
  </channel>
</rss>

