<?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: SAS dates weird , displaying as  20240399, 20240399 in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SAS-dates-weird-displaying-as-20240399-20240399/m-p/922450#M363238</link>
    <description>&lt;P&gt;Why would&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;call symput('rptdt', strip(put(date(),YYMMDDN.)-2));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Have ever worked?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That would convert a date like 01APR2024 into a string like '20240401' and convert that string into the number 20,240,401 and subtract 2 to get the number 20,240,399 then convert that into the string '&amp;nbsp; &amp;nbsp; 202403999' then convert that into the string '20240399' and finally assign it to a macro variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Are you trying to generate a digit string in YYYYMMDD style for the date that is two days before the current date?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;call symputX('rptdt', put(date()-2,YYMMDDN8.));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do you want the YEAR to reflect the date when the SAS process started (&amp;amp;sysdate or &amp;amp;sysdate9) or the when the data step ran, DATE()?&amp;nbsp; Do you want the TIME to reflect when the SAS process started (&amp;amp;systime) or when the data step ran?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There can be a big difference.&amp;nbsp; See this example where the date that is 2 days before NOW is actually after the date when I started my SAS session.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;130  data _null_;
131    now=datetime();
132    call symputX('rptdt', put(datepart(now)-2,YYMMDDN8.));
133    call symputX('time', put(timepart(now),tod5.));
134    call symputX('year', year(datepart(now)));
135  run;

NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds


136  %put &amp;amp;=rptdt &amp;amp;=time &amp;amp;=year &amp;amp;=sysdate9 &amp;amp;=systime ;
RPTDT=20240330 TIME=10:40 YEAR=2024 SYSDATE9=29MAR2024 SYSTIME=23:06

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PS Never use the &lt;STRONG&gt;ancient&lt;/STRONG&gt; CALL SYMPUT() function unless the goal is to generate a macro variable with leading and/or trailing spaces.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 01 Apr 2024 14:55:03 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2024-04-01T14:55:03Z</dc:date>
    <item>
      <title>SAS dates weird , displaying as  20240399, 20240399</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-dates-weird-displaying-as-20240399-20240399/m-p/922447#M363237</link>
      <description>&lt;P&gt;I have always used the below macro to determine the previous date and always worked :&lt;/P&gt;&lt;P&gt;data _null_;&lt;BR /&gt;year = year(input("&amp;amp;sysdate9",date9.));&lt;BR /&gt;call symput('rptdt', strip(put(date(),YYMMDDN.)-2));&lt;BR /&gt;call symput('time', put(time(), time5.));&lt;BR /&gt;call symput('year',compress(put(year,best.)));&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;but suddenly , SAS is acting weird and I am getting dates as below : it is showing as&lt;STRONG&gt; 20240399,&lt;/STRONG&gt;&amp;nbsp; in 90's series&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="desas_0-1711981360221.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/95061i1FDFE795D2E152CF/image-size/medium?v=v2&amp;amp;px=400" role="button" title="desas_0-1711981360221.png" alt="desas_0-1711981360221.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and today's date is being displayed as 20240400&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Our laptops were updated to windows11 , and this started , I am not sure If I am making a mistake or is this coincidental with windows 11.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please help&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 01 Apr 2024 14:24:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-dates-weird-displaying-as-20240399-20240399/m-p/922447#M363237</guid>
      <dc:creator>desas</dc:creator>
      <dc:date>2024-04-01T14:24:41Z</dc:date>
    </item>
    <item>
      <title>Re: SAS dates weird , displaying as  20240399, 20240399</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-dates-weird-displaying-as-20240399-20240399/m-p/922450#M363238</link>
      <description>&lt;P&gt;Why would&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;call symput('rptdt', strip(put(date(),YYMMDDN.)-2));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Have ever worked?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That would convert a date like 01APR2024 into a string like '20240401' and convert that string into the number 20,240,401 and subtract 2 to get the number 20,240,399 then convert that into the string '&amp;nbsp; &amp;nbsp; 202403999' then convert that into the string '20240399' and finally assign it to a macro variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Are you trying to generate a digit string in YYYYMMDD style for the date that is two days before the current date?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;call symputX('rptdt', put(date()-2,YYMMDDN8.));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do you want the YEAR to reflect the date when the SAS process started (&amp;amp;sysdate or &amp;amp;sysdate9) or the when the data step ran, DATE()?&amp;nbsp; Do you want the TIME to reflect when the SAS process started (&amp;amp;systime) or when the data step ran?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There can be a big difference.&amp;nbsp; See this example where the date that is 2 days before NOW is actually after the date when I started my SAS session.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;130  data _null_;
131    now=datetime();
132    call symputX('rptdt', put(datepart(now)-2,YYMMDDN8.));
133    call symputX('time', put(timepart(now),tod5.));
134    call symputX('year', year(datepart(now)));
135  run;

NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds


136  %put &amp;amp;=rptdt &amp;amp;=time &amp;amp;=year &amp;amp;=sysdate9 &amp;amp;=systime ;
RPTDT=20240330 TIME=10:40 YEAR=2024 SYSDATE9=29MAR2024 SYSTIME=23:06

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PS Never use the &lt;STRONG&gt;ancient&lt;/STRONG&gt; CALL SYMPUT() function unless the goal is to generate a macro variable with leading and/or trailing spaces.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 01 Apr 2024 14:55:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-dates-weird-displaying-as-20240399-20240399/m-p/922450#M363238</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-04-01T14:55:03Z</dc:date>
    </item>
    <item>
      <title>Re: SAS dates weird , displaying as  20240399, 20240399</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-dates-weird-displaying-as-20240399-20240399/m-p/922452#M363239</link>
      <description>Thank you so much !!</description>
      <pubDate>Mon, 01 Apr 2024 14:45:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-dates-weird-displaying-as-20240399-20240399/m-p/922452#M363239</guid>
      <dc:creator>desas</dc:creator>
      <dc:date>2024-04-01T14:45:39Z</dc:date>
    </item>
    <item>
      <title>Re: SAS dates weird , displaying as  20240399, 20240399</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-dates-weird-displaying-as-20240399-20240399/m-p/922491#M363241</link>
      <description>&lt;P&gt;Please note what makes the code from&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;work is that he does arithmetic (subtracting 2) on UN-formatted date values. Once ALL arithmetic and logical operations are done, then and only then, should you format the results and only if you need to do that&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do not try to do logical or arithmetic operations on formatted dates. Do not try to work with formatted dates (which are character strings) to perform any operations, other than to use the formatted dates in titles, labels or file names.&lt;/P&gt;</description>
      <pubDate>Mon, 01 Apr 2024 21:51:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-dates-weird-displaying-as-20240399-20240399/m-p/922491#M363241</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-04-01T21:51:59Z</dc:date>
    </item>
  </channel>
</rss>

