<?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: Getting 1965 instead of 2023 in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Getting-1965-instead-of-2023/m-p/949605#M45461</link>
    <description>&lt;P&gt;Because the number 2,021 is in the year 1965, not the year 2023.&lt;/P&gt;
&lt;PRE&gt;1    %let today=%sysfunc(mdy(1,1,2023),yymmdd10.);
2    %put &amp;amp;=today;
TODAY=2023-01-01
3    %put %sysfunc(putn(&amp;amp;today,comma7.));
2,021
4    %put %sysfunc(putn(&amp;amp;today,yymmdd10.));
1965-07-14&lt;/PRE&gt;
&lt;P&gt;Do not format the values when the formats are not needed.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let today=%sysfunc(mdy(1,1,2023));
%let curr_year=%sysfunc(year(&amp;amp;today));
%put &amp;amp;curr_year;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PS You can use the optional second argument to %SYSFUNC() to avoid needing to use PUTN() if you do need a formatted value.&amp;nbsp; Example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let month=%sysfunc(month(&amp;amp;today),z2.);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 31 Oct 2024 16:54:13 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2024-10-31T16:54:13Z</dc:date>
    <item>
      <title>Getting 1965 instead of 2023</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Getting-1965-instead-of-2023/m-p/949598#M45459</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I am using the following sas code and the current year is equal to 1965 instead of 2023 ? How to solve that issue.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let today=%sysfunc(putn(%sysfunc(mdy(1,1,2023)),yymmdd10.));
%let curr_year=%sysfunc(year(%sysfunc(putn(%sysfunc(mdy(1,1,2023)),yymmdd10.))));
%put &amp;amp;curr_year;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 31 Oct 2024 15:53:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Getting-1965-instead-of-2023/m-p/949598#M45459</guid>
      <dc:creator>alepage</dc:creator>
      <dc:date>2024-10-31T15:53:18Z</dc:date>
    </item>
    <item>
      <title>Re: Getting 1965 instead of 2023</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Getting-1965-instead-of-2023/m-p/949601#M45460</link>
      <description>&lt;P&gt;Why are you attempting to extract a YEAR value from a formatted string like 2023/01/01. The Year function expects a NUMBER as the argument so that string will be converted to a number as 2023 divided by 1 divided by 1,&amp;nbsp; or the numeric value of 2023 which the date 16 Jul 1965.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Either parse the &lt;STRONG&gt;string&lt;/STRONG&gt; with substr (or %substr) or scan/%scan or don't format the value and use the Year function on the direct result of the MDY function (which is pretty weird ) or an actual date value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;%let curr_year=%sysfunc(year(%sysfunc(mdy(1,1,2023))));
%put &amp;amp;curr_year;&lt;/PRE&gt;
&lt;P&gt;The only time the macro variable "dates" should be formatted is for use where PEOPLE read them.&lt;/P&gt;
&lt;P&gt;If you need to use any of the DATE, TIME or DATETIME functions then do not format them. As you have seen the results are likely going to be wrong.&lt;/P&gt;</description>
      <pubDate>Thu, 31 Oct 2024 16:40:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Getting-1965-instead-of-2023/m-p/949601#M45460</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-10-31T16:40:49Z</dc:date>
    </item>
    <item>
      <title>Re: Getting 1965 instead of 2023</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Getting-1965-instead-of-2023/m-p/949605#M45461</link>
      <description>&lt;P&gt;Because the number 2,021 is in the year 1965, not the year 2023.&lt;/P&gt;
&lt;PRE&gt;1    %let today=%sysfunc(mdy(1,1,2023),yymmdd10.);
2    %put &amp;amp;=today;
TODAY=2023-01-01
3    %put %sysfunc(putn(&amp;amp;today,comma7.));
2,021
4    %put %sysfunc(putn(&amp;amp;today,yymmdd10.));
1965-07-14&lt;/PRE&gt;
&lt;P&gt;Do not format the values when the formats are not needed.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let today=%sysfunc(mdy(1,1,2023));
%let curr_year=%sysfunc(year(&amp;amp;today));
%put &amp;amp;curr_year;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PS You can use the optional second argument to %SYSFUNC() to avoid needing to use PUTN() if you do need a formatted value.&amp;nbsp; Example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let month=%sysfunc(month(&amp;amp;today),z2.);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 31 Oct 2024 16:54:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Getting-1965-instead-of-2023/m-p/949605#M45461</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-10-31T16:54:13Z</dc:date>
    </item>
    <item>
      <title>Re: Getting 1965 instead of 2023</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Getting-1965-instead-of-2023/m-p/949607#M45462</link>
      <description>&lt;P&gt;If you want to use these macro variables for anything other than human-readable display, then no formatting is needed. The raw numbers work perfectly well in code.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let today = %sysfunc(mdy(1,1,2023));
%let curr_year = %sysfunc(year(&amp;amp;today.));
%put &amp;amp;curr_year;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 31 Oct 2024 16:48:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Getting-1965-instead-of-2023/m-p/949607#M45462</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2024-10-31T16:48:29Z</dc:date>
    </item>
  </channel>
</rss>

