<?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: Macro Variable as Alias in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Macro-Variable-as-Alias/m-p/810100#M319463</link>
    <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/76464"&gt;@s_lassen&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;It is working Thank you a lot!&amp;nbsp; &lt;span class="lia-unicode-emoji" title=":beaming_face_with_smiling_eyes:"&gt;😁&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 27 Apr 2022 10:22:51 GMT</pubDate>
    <dc:creator>Vidanovic</dc:creator>
    <dc:date>2022-04-27T10:22:51Z</dc:date>
    <item>
      <title>Macro Variable as Alias</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Variable-as-Alias/m-p/810076#M319449</link>
      <description>&lt;P&gt;Dear SAS experts,&lt;BR /&gt;&lt;BR /&gt;Is there a possible solution to use macro variable as alias when the returned value of macro is number?&lt;BR /&gt;I want to rewrite a column name as &lt;STRONG&gt;202203.&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;PRE&gt;%let date = %sysfunc(today());
%let me = %sysfunc(intnx(month,&amp;amp;date,-1),yymmn6.);
%put &amp;amp;me;

proc sql;
create table final as
select client_id
      ,iznos_rsd as &amp;amp;me
from pom;
quit;&lt;/PRE&gt;&lt;P&gt;Thank you very much in advance&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":smiling_face_with_smiling_eyes:"&gt;😊&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Apr 2022 07:30:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Variable-as-Alias/m-p/810076#M319449</guid>
      <dc:creator>Vidanovic</dc:creator>
      <dc:date>2022-04-27T07:30:08Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Variable as Alias</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Variable-as-Alias/m-p/810077#M319450</link>
      <description>&lt;P&gt;Why do you want a date as part of a variable name?&lt;/P&gt;
&lt;P&gt;Dates are&amp;nbsp;&lt;EM&gt;data&lt;/EM&gt; and do not belong in&amp;nbsp;&lt;EM&gt;structure&lt;/EM&gt;, so this looks like bad data design overall.&lt;/P&gt;
&lt;P&gt;What do you intend to do with this column later on?&lt;/P&gt;</description>
      <pubDate>Wed, 27 Apr 2022 07:45:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Variable-as-Alias/m-p/810077#M319450</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-04-27T07:45:26Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Variable as Alias</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Variable-as-Alias/m-p/810094#M319462</link>
      <description>&lt;P&gt;If you want the number as a column value, you will have to refer to it as e.g. "202203"n.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So this code will probably work:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let date = %sysfunc(today());
%let me = %sysfunc(intnx(month,&amp;amp;date,-1),yymmn6.);
%put &amp;amp;me;

proc sql;
create table final as
select client_id
      ,iznos_rsd as "&amp;amp;me"n
from pom;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;but you will have to refer to it the same way in all the programming that follows. This is needed because SAS must know that you are referring to a variable and not a numeric constant.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Apr 2022 09:23:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Variable-as-Alias/m-p/810094#M319462</guid>
      <dc:creator>s_lassen</dc:creator>
      <dc:date>2022-04-27T09:23:14Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Variable as Alias</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Variable-as-Alias/m-p/810100#M319463</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/76464"&gt;@s_lassen&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;It is working Thank you a lot!&amp;nbsp; &lt;span class="lia-unicode-emoji" title=":beaming_face_with_smiling_eyes:"&gt;😁&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Apr 2022 10:22:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Variable-as-Alias/m-p/810100#M319463</guid>
      <dc:creator>Vidanovic</dc:creator>
      <dc:date>2022-04-27T10:22:51Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Variable as Alias</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Variable-as-Alias/m-p/810101#M319464</link>
      <description>&lt;P&gt;When SAS executes code with macro variables, it replaces the macro variable with its value. So your code will run as&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table final as
select client_id
      ,iznos_rsd as 202203
from pom;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;which won't work either. This is not legal working SAS code. Can you see why?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, the first thing you need to do is to create working SAS code that does what you want for the date 202203 WITHOUT macro variables. If it doesn't work without macro variables, then it also won't work with macro variables. Many people seem to ignore this advice; don't be one of those people, because your usage of macro variables won't work if you don't first write code that works without macro variables.&lt;/P&gt;</description>
      <pubDate>Wed, 27 Apr 2022 10:23:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Variable-as-Alias/m-p/810101#M319464</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-04-27T10:23:37Z</dc:date>
    </item>
  </channel>
</rss>

