<?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 Creating Variables from Expressions in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Creating-Variables-from-Expressions/m-p/551394#M153188</link>
    <description>&lt;P&gt;Is there a way to create variables like - DEC_2020 etc..from:&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;%macro&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; &lt;STRONG&gt;&lt;I&gt;stupid&lt;/I&gt;&lt;/STRONG&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;create table B as&lt;/P&gt;&lt;P&gt;select *&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%do&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; i=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%to&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;6&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;,&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt; as &lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'DEC_'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;||&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%EVAL&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;(&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;2019&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;+&amp;amp;&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;i.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;)&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%end&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;from A;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;%mend&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;The expression &lt;FONT color="#800080" face="Courier New" size="3"&gt;'DEC_'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;||&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%EVAL&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;(&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;2019&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;+&amp;amp;&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;I.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;)&lt;/FONT&gt; is not working as expected, but is there a function or any other way where I can get this to work?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 16 Apr 2019 14:55:49 GMT</pubDate>
    <dc:creator>thepushkarsingh</dc:creator>
    <dc:date>2019-04-16T14:55:49Z</dc:date>
    <item>
      <title>Creating Variables from Expressions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-Variables-from-Expressions/m-p/551394#M153188</link>
      <description>&lt;P&gt;Is there a way to create variables like - DEC_2020 etc..from:&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;%macro&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; &lt;STRONG&gt;&lt;I&gt;stupid&lt;/I&gt;&lt;/STRONG&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;create table B as&lt;/P&gt;&lt;P&gt;select *&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%do&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; i=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%to&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;6&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;,&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt; as &lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'DEC_'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;||&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%EVAL&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;(&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;2019&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;+&amp;amp;&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;i.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;)&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%end&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;from A;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;%mend&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;The expression &lt;FONT color="#800080" face="Courier New" size="3"&gt;'DEC_'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;||&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%EVAL&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;(&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;2019&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;+&amp;amp;&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;I.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;)&lt;/FONT&gt; is not working as expected, but is there a function or any other way where I can get this to work?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 16 Apr 2019 14:55:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-Variables-from-Expressions/m-p/551394#M153188</guid>
      <dc:creator>thepushkarsingh</dc:creator>
      <dc:date>2019-04-16T14:55:49Z</dc:date>
    </item>
    <item>
      <title>Re: Creating Variables from Expressions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-Variables-from-Expressions/m-p/551395#M153189</link>
      <description>&lt;P&gt;Are you required to use SQL?&lt;/P&gt;
&lt;P&gt;A data step can be easier.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Otherwise, remove the quotes around Dec and the || and see if you get what you need.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/194934"&gt;@thepushkarsingh&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Is there a way to create variables like - DEC_2020 etc..from:&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#000080"&gt;&lt;STRONG&gt;%macro&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; &lt;STRONG&gt;&lt;I&gt;stupid&lt;/I&gt;&lt;/STRONG&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;/P&gt;
&lt;P&gt;create table B as&lt;/P&gt;
&lt;P&gt;select *&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;%do&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; i=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="3" color="#008080"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT face="Courier New" size="3" color="#0000ff"&gt;%to&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT face="Courier New" size="3" color="#008080"&gt;6&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;,&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="3" color="#008080"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt; as &lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#800080"&gt;'DEC_'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;||&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;%EVAL&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;(&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="3" color="#008080"&gt;2019&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;+&amp;amp;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#008080"&gt;i.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;)&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;%end&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;from A;&lt;/P&gt;
&lt;P&gt;quit;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3" color="#000080"&gt;&lt;STRONG&gt;%mend&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;The expression &lt;FONT face="Courier New" size="3" color="#800080"&gt;'DEC_'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;||&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#0000ff"&gt;%EVAL&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;(&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="3" color="#008080"&gt;2019&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;+&amp;amp;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#008080"&gt;I.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;)&lt;/FONT&gt; is not working as expected, but is there a function or any other way where I can get this to work?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 16 Apr 2019 15:01:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-Variables-from-Expressions/m-p/551395#M153189</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-04-16T15:01:59Z</dc:date>
    </item>
    <item>
      <title>Re: Creating Variables from Expressions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-Variables-from-Expressions/m-p/551396#M153190</link>
      <description>&lt;P&gt;"Are you required to use SQL?&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;A data step can be easier."&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That's sound of a real professional who knows stuff&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 16 Apr 2019 15:03:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-Variables-from-Expressions/m-p/551396#M153190</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-04-16T15:03:53Z</dc:date>
    </item>
    <item>
      <title>Re: Creating Variables from Expressions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-Variables-from-Expressions/m-p/551399#M153191</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/194934"&gt;@thepushkarsingh&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Is there a way to create variables like - DEC_2020 etc..from:&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;%macro&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; &lt;STRONG&gt;&lt;I&gt;stupid&lt;/I&gt;&lt;/STRONG&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;/P&gt;
&lt;P&gt;create table B as&lt;/P&gt;
&lt;P&gt;select *&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%do&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; i=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%to&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;6&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;,&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt; as &lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'DEC_'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;||&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%EVAL&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;(&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;2019&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;+&amp;amp;&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;i.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;)&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%end&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;from A;&lt;/P&gt;
&lt;P&gt;quit;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;%mend&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;The expression &lt;FONT color="#800080" face="Courier New" size="3"&gt;'DEC_'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;||&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%EVAL&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;(&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;2019&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;+&amp;amp;&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;I.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;)&lt;/FONT&gt; is not working as expected, but is there a function or any other way where I can get this to work?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;One way:&lt;/P&gt;
&lt;PRE&gt;%macro stupid;
   proc sql;
   create table B as
   select *
   %do i=1 %to 6;
      %let temp= %eval(2019+&amp;amp;i.);
   ,1 as DEC_&amp;amp;temp.
   %end;
   from a;
   quit;
%mend;&lt;/PRE&gt;
&lt;P&gt;macro language does concatenation a bit differently so you don't need the || operator. Also variable names in SQL can't be in quotes.&lt;/P&gt;
&lt;P&gt;I create a temporary variable so it is a bit clearer what happens with the DEC_&amp;amp;temp. string.&lt;/P&gt;
&lt;PRE&gt;,1 as DEC_%eval(2019+&amp;amp;i.)&lt;/PRE&gt;
&lt;P&gt;also works but can be a bit ugly AND you do not want a space before the %eval, which makes the code a tad uglier&lt;/P&gt;</description>
      <pubDate>Tue, 16 Apr 2019 15:06:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-Variables-from-Expressions/m-p/551399#M153191</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-04-16T15:06:17Z</dc:date>
    </item>
    <item>
      <title>Re: Creating Variables from Expressions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-Variables-from-Expressions/m-p/551400#M153192</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You are building variable names not strings containing variable names.&lt;/P&gt;
&lt;P&gt;Hence the quotes and the concatenation operator are superfluous.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro stupid;

	proc sql;
		create table B as
		select *
		%do i=1 %to 6;
		    %let vname=DEC_%eval(2019+&amp;amp;i.);
		    ,1 as &amp;amp;vname.
		%end;
		from sashelp.class;
	quit;

%mend;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;It would be simpler with a data step (no macro necessary).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data C;
    set sashelp.class;
    attrib DEC_2020-DEC_2025 length=3.;
    array DEC DEC_2020-DEC_2025;

    do over DEC;
        DEC=1;
    end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 16 Apr 2019 15:08:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-Variables-from-Expressions/m-p/551400#M153192</guid>
      <dc:creator>gamotte</dc:creator>
      <dc:date>2019-04-16T15:08:39Z</dc:date>
    </item>
    <item>
      <title>Re: Creating Variables from Expressions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-Variables-from-Expressions/m-p/551401#M153194</link>
      <description>&lt;P&gt;Apologies, I constructed a wrong example(SQL is definitely not needed).&lt;/P&gt;&lt;P&gt;What I intend to ask is&amp;nbsp;'is there a way(any function)&amp;nbsp;to evaluate an expression, which takes value from another variable&amp;nbsp;and use it as a reference&amp;nbsp;to a variable?'.&lt;/P&gt;&lt;P&gt;Like let's say the variable start_date is populated as-&lt;/P&gt;&lt;P&gt;start_date&lt;/P&gt;&lt;P&gt;DEC2021&lt;/P&gt;&lt;P&gt;APR2022&lt;/P&gt;&lt;P&gt;JUN2025&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;And accordingly the reference changes from Variable VAR_2021 to VAR_2022 to VAR_2025 for different rows.&lt;/P&gt;</description>
      <pubDate>Tue, 16 Apr 2019 15:12:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-Variables-from-Expressions/m-p/551401#M153194</guid>
      <dc:creator>thepushkarsingh</dc:creator>
      <dc:date>2019-04-16T15:12:30Z</dc:date>
    </item>
    <item>
      <title>Re: Creating Variables from Expressions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-Variables-from-Expressions/m-p/551408#M153197</link>
      <description>&lt;P&gt;&amp;nbsp;I think you have to explain more clearly exactly what you want to do.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Does this answer your question ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
informat start_date anydtdte.;
input start_date var_2021 var_2022 var_2025;

value=vvaluex(cats('var_',year(start_date)));
put value=;
cards;
DEC2021 1 2 3
APR2022 4 5 6
JUN2025 7 8 9
;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 16 Apr 2019 15:22:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-Variables-from-Expressions/m-p/551408#M153197</guid>
      <dc:creator>gamotte</dc:creator>
      <dc:date>2019-04-16T15:22:15Z</dc:date>
    </item>
    <item>
      <title>Re: Creating Variables from Expressions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-Variables-from-Expressions/m-p/551410#M153198</link>
      <description>&lt;P&gt;Thank you very much.&lt;/P&gt;</description>
      <pubDate>Tue, 16 Apr 2019 15:25:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-Variables-from-Expressions/m-p/551410#M153198</guid>
      <dc:creator>thepushkarsingh</dc:creator>
      <dc:date>2019-04-16T15:25:09Z</dc:date>
    </item>
  </channel>
</rss>

