<?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 numeric variable from current date. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Creating-numeric-variable-from-current-date/m-p/822363#M324736</link>
    <description>Okay, I am sure I am just missing something simple, but I can’t figure it out.&lt;BR /&gt;&lt;BR /&gt;I have a data set where the date is broken down in to three separate variable (month, day, and year), all of which are formatted as Best12.&lt;BR /&gt;&lt;BR /&gt;I am trying to make a macro of the current year and reformat it into best12. for the purpose of exclusion/inclusion.&lt;BR /&gt;&lt;BR /&gt;I know how to use both call symputx and %Let to extract just the year for a macro, but I need to transform it into a numeric with Best12. So when I subset the data I can do it by calling the macro.&lt;BR /&gt;&lt;BR /&gt;I can’t quite figure out how to do that though…any ideas?</description>
    <pubDate>Fri, 08 Jul 2022 21:25:57 GMT</pubDate>
    <dc:creator>G-Scott</dc:creator>
    <dc:date>2022-07-08T21:25:57Z</dc:date>
    <item>
      <title>Creating numeric variable from current date.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-numeric-variable-from-current-date/m-p/822363#M324736</link>
      <description>Okay, I am sure I am just missing something simple, but I can’t figure it out.&lt;BR /&gt;&lt;BR /&gt;I have a data set where the date is broken down in to three separate variable (month, day, and year), all of which are formatted as Best12.&lt;BR /&gt;&lt;BR /&gt;I am trying to make a macro of the current year and reformat it into best12. for the purpose of exclusion/inclusion.&lt;BR /&gt;&lt;BR /&gt;I know how to use both call symputx and %Let to extract just the year for a macro, but I need to transform it into a numeric with Best12. So when I subset the data I can do it by calling the macro.&lt;BR /&gt;&lt;BR /&gt;I can’t quite figure out how to do that though…any ideas?</description>
      <pubDate>Fri, 08 Jul 2022 21:25:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-numeric-variable-from-current-date/m-p/822363#M324736</guid>
      <dc:creator>G-Scott</dc:creator>
      <dc:date>2022-07-08T21:25:57Z</dc:date>
    </item>
    <item>
      <title>Re: Creating numeric variable from current date.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-numeric-variable-from-current-date/m-p/822368#M324738</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/347039"&gt;@G-Scott&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;BR /&gt;I have a data set where the date is broken down in to three separate variable (month, day, and year), all of which are formatted as Best12.&lt;BR /&gt;&lt;BR /&gt;I am trying to make a macro of the current year and reformat it into best12. for the purpose of exclusion/inclusion.&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I tend to be picky about terminology things like this, but you want a macro variable, and not a macro. These two are not the same.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Macro variables are not formatted, and they are always 100% of the time character. There's no such things as a numeric macro variable, even though it may look numeric to humans.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So you have a year variable in a SAS data set, to make it into a macro variable this is how you do it in a DATA step in SAS:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;call symputx('year',year);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;No formatting is needed. After the DATA step ends, if you execute this command, you will see that macro variable &amp;amp;year has the proper value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%put &amp;amp;=year;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;I need to transform it into a numeric with Best12. So when I subset the data I can do it by calling the macro.&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can just use &amp;amp;year without any formatting at all. When you subset the data, you are performing a logical (Boolean) operation, something like this DATA step command:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;if year &amp;lt; &amp;amp;year;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;and these logical (Boolean) operations (and also arithmetic operations) are ALWAYS (that's 100% of the time, ALWAYS) performed by SAS on the un-formatted values. So not only does it not matter what the format is, but SAS does not use the format in such cases.&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Jul 2022 21:34:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-numeric-variable-from-current-date/m-p/822368#M324738</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-07-08T21:34:19Z</dc:date>
    </item>
    <item>
      <title>Re: Creating numeric variable from current date.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-numeric-variable-from-current-date/m-p/822369#M324739</link>
      <description>&lt;P&gt;Macro variables are not numeric; the macro language works with&amp;nbsp;&lt;EM&gt;text&lt;/EM&gt; only, and this text is inserted wherever the macro variable is used in code.&lt;/P&gt;
&lt;P&gt;So this works:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let curr_year = 2022;

data want;
set have;
where year = &amp;amp;curr_year.;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 08 Jul 2022 21:32:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-numeric-variable-from-current-date/m-p/822369#M324739</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-07-08T21:32:56Z</dc:date>
    </item>
    <item>
      <title>Re: Creating numeric variable from current date.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-numeric-variable-from-current-date/m-p/823379#M325100</link>
      <description>I appreciate you outlining some of the terminology. That is actually helpful.</description>
      <pubDate>Thu, 14 Jul 2022 18:08:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-numeric-variable-from-current-date/m-p/823379#M325100</guid>
      <dc:creator>G-Scott</dc:creator>
      <dc:date>2022-07-14T18:08:44Z</dc:date>
    </item>
  </channel>
</rss>

