<?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 Macro functionality in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Macro-functionality/m-p/65543#M14239</link>
    <description>Hi All,&lt;BR /&gt;
&lt;BR /&gt;
   I have a situation like, I have two macro varibales "Y2008" &amp;amp; "Y2009" with the values of  7 , 3 respectively. on the otherside, my data files has one variable "YEAR_END" and two obervarion with the values of 2008 &amp;amp; 2009. I have to resolve this YEAR_END vairbal with the above macro values (7 ,3) . &lt;BR /&gt;
&lt;BR /&gt;
   Please do see my code,&lt;BR /&gt;
&lt;BR /&gt;
%let Y2008 = 7 ;&lt;BR /&gt;
%let Y2009 = 3 ;&lt;BR /&gt;
&lt;BR /&gt;
data data1;&lt;BR /&gt;
input YEAR_END $4.;&lt;BR /&gt;
out_var = &amp;amp;Y.&amp;amp;YEAR_END. ;    &amp;lt;-- here i am getting error&lt;BR /&gt;
cards;&lt;BR /&gt;
2008&lt;BR /&gt;
2009&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
I want the output of data1 is,&lt;BR /&gt;
out_var = 7  YEAR_END=2008&lt;BR /&gt;
out_var =3  YEAR_END=2009&lt;BR /&gt;
&lt;BR /&gt;
Kindly note, i don't want to hard code if condition , like, if YEAR_END=2008 then out_var = &amp;amp;Y2008&lt;BR /&gt;
Thanks,</description>
    <pubDate>Mon, 24 Jan 2011 19:47:10 GMT</pubDate>
    <dc:creator>DPraba79</dc:creator>
    <dc:date>2011-01-24T19:47:10Z</dc:date>
    <item>
      <title>Macro functionality</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-functionality/m-p/65543#M14239</link>
      <description>Hi All,&lt;BR /&gt;
&lt;BR /&gt;
   I have a situation like, I have two macro varibales "Y2008" &amp;amp; "Y2009" with the values of  7 , 3 respectively. on the otherside, my data files has one variable "YEAR_END" and two obervarion with the values of 2008 &amp;amp; 2009. I have to resolve this YEAR_END vairbal with the above macro values (7 ,3) . &lt;BR /&gt;
&lt;BR /&gt;
   Please do see my code,&lt;BR /&gt;
&lt;BR /&gt;
%let Y2008 = 7 ;&lt;BR /&gt;
%let Y2009 = 3 ;&lt;BR /&gt;
&lt;BR /&gt;
data data1;&lt;BR /&gt;
input YEAR_END $4.;&lt;BR /&gt;
out_var = &amp;amp;Y.&amp;amp;YEAR_END. ;    &amp;lt;-- here i am getting error&lt;BR /&gt;
cards;&lt;BR /&gt;
2008&lt;BR /&gt;
2009&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
I want the output of data1 is,&lt;BR /&gt;
out_var = 7  YEAR_END=2008&lt;BR /&gt;
out_var =3  YEAR_END=2009&lt;BR /&gt;
&lt;BR /&gt;
Kindly note, i don't want to hard code if condition , like, if YEAR_END=2008 then out_var = &amp;amp;Y2008&lt;BR /&gt;
Thanks,</description>
      <pubDate>Mon, 24 Jan 2011 19:47:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-functionality/m-p/65543#M14239</guid>
      <dc:creator>DPraba79</dc:creator>
      <dc:date>2011-01-24T19:47:10Z</dc:date>
    </item>
    <item>
      <title>Re: Macro functionality</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-functionality/m-p/65544#M14240</link>
      <description>What you are wanting to use is "macro variable" resolution within your DATA step.&lt;BR /&gt;
&lt;BR /&gt;
So, you want the SYMGET function within your DATA step and concatenate the character "Y" with the "input character variable YEAR_END.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Suggested Google advanced search argument, this topic / post:&lt;BR /&gt;
&lt;BR /&gt;
data step programming symget function site:sas.com

Message was edited by: sbb</description>
      <pubDate>Mon, 24 Jan 2011 19:57:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-functionality/m-p/65544#M14240</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2011-01-24T19:57:37Z</dc:date>
    </item>
    <item>
      <title>Re: Macro functionality</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-functionality/m-p/65545#M14241</link>
      <description>Hi. call execute is very useful for your situation.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
%let Y2008 = 7 ;&lt;BR /&gt;
%let Y2009 = 3 ;&lt;BR /&gt;
&lt;BR /&gt;
data _null_;&lt;BR /&gt;
input YEAR_END $4.;&lt;BR /&gt;
&lt;BR /&gt;
if _n_ eq 1 then  call execute('data data1;');&lt;BR /&gt;
call execute('out_var=&amp;amp;Y'||year_end||';');&lt;BR /&gt;
call execute('year_end='||year_end||';');&lt;BR /&gt;
call execute('output;');&lt;BR /&gt;
&lt;BR /&gt;
datalines;&lt;BR /&gt;
2008&lt;BR /&gt;
2009&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Ksharp</description>
      <pubDate>Tue, 25 Jan 2011 03:34:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-functionality/m-p/65545#M14241</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2011-01-25T03:34:57Z</dc:date>
    </item>
    <item>
      <title>Re: Macro functionality</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-functionality/m-p/65546#M14242</link>
      <description>Hello,&lt;BR /&gt;
&lt;BR /&gt;
you can try the resolve function with &lt;B&gt; single &lt;/B&gt; quotes in order to delay the resolution until the DATA step executes:&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
data data1;&lt;BR /&gt;
input YEAR_END $4.;&lt;BR /&gt;
out_var=input(resolve(cats('&amp;amp;Y',YEAR_END)),best12.);&lt;BR /&gt;
cards;&lt;BR /&gt;
2008&lt;BR /&gt;
2009&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
[pre]&lt;BR /&gt;
&lt;BR /&gt;
Marius</description>
      <pubDate>Tue, 25 Jan 2011 14:58:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-functionality/m-p/65546#M14242</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2011-01-25T14:58:32Z</dc:date>
    </item>
    <item>
      <title>Re: Macro functionality</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-functionality/m-p/65547#M14243</link>
      <description>Great!&lt;BR /&gt;
Which remaind me another simple solution.&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
&lt;BR /&gt;
%let Y2008 = 7 ;&lt;BR /&gt;
%let Y2009 = 3 ;&lt;BR /&gt;
data data1;&lt;BR /&gt;
input YEAR_END $4.;&lt;BR /&gt;
out_var=symgetn('Y'||year_end);&lt;BR /&gt;
cards;&lt;BR /&gt;
2008&lt;BR /&gt;
2009&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
Ksharp</description>
      <pubDate>Wed, 26 Jan 2011 05:36:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-functionality/m-p/65547#M14243</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2011-01-26T05:36:52Z</dc:date>
    </item>
  </channel>
</rss>

