<?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: Sysfunc date in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Sysfunc-date/m-p/794969#M254957</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/35213"&gt;@Kiteulf&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Whilst it is typically better to work with SAS dates, they are not very human readable. Have you tried formatting (e.g., datetime20.) the value by using a second argument to %sysfunc() as below?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let begTrans = 
 %sysfunc(
  intnx(
   dtyear,              /* unit of time interval */
   %sysfunc(datetime()), /* function to get current datetime */
   -1 ,                   /* number of intervals, negative goes to the past */
   beginning                  /* alignment of interval date. "Same" is for same day of month/same time , "beginning" as start, end as ending*/
   )
   ,datetime20.
  );
 %put &amp;amp;=begTrans;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This gives the following in the log:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;BEGTRANS=01JAN2021:00:00:00&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Kind regards,&lt;/P&gt;
&lt;P&gt;Amir.&lt;/P&gt;</description>
    <pubDate>Tue, 08 Feb 2022 12:36:05 GMT</pubDate>
    <dc:creator>Amir</dc:creator>
    <dc:date>2022-02-08T12:36:05Z</dc:date>
    <item>
      <title>Sysfunc date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sysfunc-date/m-p/794968#M254956</link>
      <description>&lt;PRE&gt;%let begTrans = 
 %sysfunc(
  intnx(
   dtyear,              /* unit of time interval */
   %sysfunc(datetime()), /* function to get current datetime */
   -1 ,                   /* number of intervals, negative goes to the past */
   beginning                  /* alignment of interval date. "Same" is for same day of month/same time , "beginning" as start, end as ending*/
   )
  );
 %put &amp;amp;=begTrans;&lt;/PRE&gt;
&lt;P&gt;why is just using the same, when I have written beginning ? I want it to keep 01Jan until we get to a new year then it will do the change&lt;/P&gt;</description>
      <pubDate>Tue, 08 Feb 2022 12:12:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sysfunc-date/m-p/794968#M254956</guid>
      <dc:creator>Kiteulf</dc:creator>
      <dc:date>2022-02-08T12:12:56Z</dc:date>
    </item>
    <item>
      <title>Re: Sysfunc date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sysfunc-date/m-p/794969#M254957</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/35213"&gt;@Kiteulf&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Whilst it is typically better to work with SAS dates, they are not very human readable. Have you tried formatting (e.g., datetime20.) the value by using a second argument to %sysfunc() as below?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let begTrans = 
 %sysfunc(
  intnx(
   dtyear,              /* unit of time interval */
   %sysfunc(datetime()), /* function to get current datetime */
   -1 ,                   /* number of intervals, negative goes to the past */
   beginning                  /* alignment of interval date. "Same" is for same day of month/same time , "beginning" as start, end as ending*/
   )
   ,datetime20.
  );
 %put &amp;amp;=begTrans;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This gives the following in the log:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;BEGTRANS=01JAN2021:00:00:00&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Kind regards,&lt;/P&gt;
&lt;P&gt;Amir.&lt;/P&gt;</description>
      <pubDate>Tue, 08 Feb 2022 12:36:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sysfunc-date/m-p/794969#M254957</guid>
      <dc:creator>Amir</dc:creator>
      <dc:date>2022-02-08T12:36:05Z</dc:date>
    </item>
    <item>
      <title>Re: Sysfunc date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sysfunc-date/m-p/794970#M254958</link>
      <description>&lt;P&gt;I'm not sure I see anything working incorrectly here.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let begTrans = 
 %sysfunc(
  intnx(dtyear,%sysfunc(datetime()),-1,beginning)
  );
 %put &amp;amp;=begTrans %sysfunc(putn(&amp;amp;begtrans,datetime16.));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Results in:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;BEGTRANS=1925078400 01JAN21:00:00:00
&lt;/PRE&gt;
&lt;P&gt;which is correct.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Next year, when the date is 08FEB2023, I get&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let nextyear=%sysevalf('08FEB2023:00:00:00'dt);
%let begTrans = 
 %sysfunc(
  intnx(dtyear,&amp;amp;nextyear,-1,beginning)
  );
 %put &amp;amp;=begTrans %sysfunc(putn(&amp;amp;begtrans,datetime16.));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;the result is&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;BEGTRANS=1956614400 01JAN22:00:00:00
&lt;/PRE&gt;
&lt;P&gt;which is also correct.&lt;/P&gt;</description>
      <pubDate>Tue, 08 Feb 2022 12:42:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sysfunc-date/m-p/794970#M254958</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-02-08T12:42:57Z</dc:date>
    </item>
  </channel>
</rss>

