<?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: Datetime formats in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Datetime-formats/m-p/915084#M360593</link>
    <description>Thank you,&lt;BR /&gt;&lt;BR /&gt;I have the date 20240208T160242,&lt;BR /&gt;could I have the same date without T ?&lt;BR /&gt;&lt;BR /&gt;Yes, I use the variable for the file name.</description>
    <pubDate>Thu, 08 Feb 2024 15:06:08 GMT</pubDate>
    <dc:creator>SASdevAnneMarie</dc:creator>
    <dc:date>2024-02-08T15:06:08Z</dc:date>
    <item>
      <title>Datetime formats</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Datetime-formats/m-p/915020#M360582</link>
      <description>&lt;P&gt;Hello Experts,&lt;/P&gt;
&lt;P&gt;I use %sysfunc(today(), yymmddn8.) for creating the macro variable.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do you know please how to get the dates in format :&lt;/P&gt;
&lt;P&gt;20240208115859 and 2024020811 ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you !&lt;/P&gt;</description>
      <pubDate>Thu, 08 Feb 2024 11:02:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Datetime-formats/m-p/915020#M360582</guid>
      <dc:creator>SASdevAnneMarie</dc:creator>
      <dc:date>2024-02-08T11:02:44Z</dc:date>
    </item>
    <item>
      <title>Re: Datetime formats</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Datetime-formats/m-p/915022#M360584</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let dt = %sysfunc(datetime(),b8601dt.);
%put &amp;amp;=dt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Of course, if you don't like the b8601dt. format, pick another one that works better for you. Or modify &amp;amp;dt, it's just text at this point.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;CAUTION: formatting macro variables like this is normally not required and just extra work in most cases. If this macro variable is going to be used for arithmetic or logical operations, no need to format it (in fact, formatting it in these cases would not produce the desired results). Unless this macro variable is going to be used in a title or label or file name (such as a title that says "Data as of &amp;amp;dt"), don't bother formatting macro variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;CAUTION 2: &lt;SPAN&gt;20240208115859 can be interpreted as August 2 or February&amp;nbsp;8, its never clear which and can be confusing. The datetime19. format eliminates this possible confusion. But it depends on what you are going to do with this macro variable.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;So that's twice I mention that it depends on what you are going to do with this macro variable. Please tell us how it will be used. Context is everything, and you have given us no context.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Feb 2024 12:04:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Datetime-formats/m-p/915022#M360584</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-02-08T12:04:55Z</dc:date>
    </item>
    <item>
      <title>Re: Datetime formats</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Datetime-formats/m-p/915084#M360593</link>
      <description>Thank you,&lt;BR /&gt;&lt;BR /&gt;I have the date 20240208T160242,&lt;BR /&gt;could I have the same date without T ?&lt;BR /&gt;&lt;BR /&gt;Yes, I use the variable for the file name.</description>
      <pubDate>Thu, 08 Feb 2024 15:06:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Datetime-formats/m-p/915084#M360593</guid>
      <dc:creator>SASdevAnneMarie</dc:creator>
      <dc:date>2024-02-08T15:06:08Z</dc:date>
    </item>
    <item>
      <title>Re: Datetime formats</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Datetime-formats/m-p/915087#M360595</link>
      <description>&lt;P&gt;Use COMPRESS:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let dt =%sysfunc(compress(%sysfunc(datetime(),b8601dt19.),T));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;or roll your own PICTURE format with PROC FORMAT.&lt;/P&gt;
&lt;P&gt;Or build it piecemeal:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let dt = %sysfunc(today(),yymmddn8.)%sysfunc(time(),b8601tm6.);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 08 Feb 2024 15:33:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Datetime-formats/m-p/915087#M360595</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2024-02-08T15:33:44Z</dc:date>
    </item>
    <item>
      <title>Re: Datetime formats</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Datetime-formats/m-p/915092#M360599</link>
      <description>&lt;P&gt;As your subject line makes clear those last two strings are not DATE values.&amp;nbsp; They are DATETIME values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Use the DATETIME() function to get the current datetime.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let dt=%sysfunc(datetime());&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or use some other datetime value you have available, such as when the current SAS session started which is recorded in SYSDATE9 and SYSTIME macro variables.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let dt="&amp;amp;sysdate9:&amp;amp;systime"dt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Now you can use a number of methods to build your digit string.&lt;/P&gt;
&lt;P&gt;You might use a format that has the right digits in the right order and then remove the punctuation it uses to make the values human readable.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let dtstring = %sysfunc(compress(%sysfunc(putn(&amp;amp;dt,e8601dt19.)),T:-));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or perhaps replace them with some character like _ that is valid in a filename.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let dtstring = %sysfunc(translate(%sysfunc(putn(&amp;amp;dt,e8601dt19.)),___,T:-));&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 08 Feb 2024 15:46:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Datetime-formats/m-p/915092#M360599</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-02-08T15:46:32Z</dc:date>
    </item>
    <item>
      <title>Re: Datetime formats</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Datetime-formats/m-p/915093#M360600</link>
      <description>&lt;P&gt;I agree that 0802&lt;SPAN&gt;2024 can be interpreted as August 2 or February&amp;nbsp;8, but no way for 20240208. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Bart&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Feb 2024 15:49:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Datetime-formats/m-p/915093#M360600</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2024-02-08T15:49:49Z</dc:date>
    </item>
  </channel>
</rss>

