<?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: How to create system time in a specific format &amp;quot;Hour_Minute_Second&amp;quot;? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-system-time-in-a-specific-format-quot-Hour-Minute/m-p/913691#M360096</link>
    <description>&lt;P&gt;Convert the time to a text string using the PUT function, then use the TRANSLATE function to change : to _&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
    starttime1=time();
    call symputx('excel_time',translate(put(starttime1,time.),'_',':'));
run;
%put &amp;amp;=excel_time;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 30 Jan 2024 22:54:02 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2024-01-30T22:54:02Z</dc:date>
    <item>
      <title>How to create system time in a specific format "Hour_Minute_Second"?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-system-time-in-a-specific-format-quot-Hour-Minute/m-p/913688#M360094</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I have a program below, and I would like to output an Excel file name appending with the&amp;nbsp;program's starting running time.&amp;nbsp; I found the format is not recognized by the macro.&amp;nbsp; Please help, thanks.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let StartTime1 = %sysfunc(datetime(), datetime20.);

ods excel file="Pathway\Test_&amp;amp;starttime1..xlsx";&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;And the log shows&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;LI-SPOILER&gt;SYMBOLGEN: Macro variable STARTFMT resolves to .&lt;BR /&gt;53 %let StartTime1 = %sysfunc(datetime(), datetime20.);&lt;BR /&gt;54&lt;BR /&gt;55 ods excel&lt;BR /&gt;55 ! file="Pathway\test_&amp;amp;starttime1..xlsx";&lt;BR /&gt;SYMBOLGEN: Macro variable STARTTIME1 resolves to 30JAN2024:17:30:44&lt;BR /&gt;ERROR: Physical file does not exist,&lt;BR /&gt;Pathway\test_30JAN2024:17:30:\05.xlsx.
&lt;LI-SPOILER&gt;
&lt;LI-SPOILER&gt;&amp;nbsp;&lt;/LI-SPOILER&gt;
&lt;/LI-SPOILER&gt;
&lt;/LI-SPOILER&gt;
&lt;/BLOCKQUOTE&gt;</description>
      <pubDate>Tue, 30 Jan 2024 22:33:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-system-time-in-a-specific-format-quot-Hour-Minute/m-p/913688#M360094</guid>
      <dc:creator>ybz12003</dc:creator>
      <dc:date>2024-01-30T22:33:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to create system time in a specific format "Hour_Minute_Second"?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-system-time-in-a-specific-format-quot-Hour-Minute/m-p/913690#M360095</link>
      <description>&lt;P&gt;The&amp;nbsp;&lt;SPAN&gt;STARTTIME1 resolves to 30JAN2024:17:30:44, which is not suitable for the title.&amp;nbsp; Is there a way to change to "30JAN2024_17_30_44"?&amp;nbsp; Thanks.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Jan 2024 22:36:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-system-time-in-a-specific-format-quot-Hour-Minute/m-p/913690#M360095</guid>
      <dc:creator>ybz12003</dc:creator>
      <dc:date>2024-01-30T22:36:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to create system time in a specific format "Hour_Minute_Second"?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-system-time-in-a-specific-format-quot-Hour-Minute/m-p/913691#M360096</link>
      <description>&lt;P&gt;Convert the time to a text string using the PUT function, then use the TRANSLATE function to change : to _&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
    starttime1=time();
    call symputx('excel_time',translate(put(starttime1,time.),'_',':'));
run;
%put &amp;amp;=excel_time;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Jan 2024 22:54:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-system-time-in-a-specific-format-quot-Hour-Minute/m-p/913691#M360096</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-01-30T22:54:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to create system time in a specific format "Hour_Minute_Second"?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-system-time-in-a-specific-format-quot-Hour-Minute/m-p/913692#M360097</link>
      <description>&lt;P&gt;If you are going to use this frequently it may be worth writing a custom format. At which point I might recommend using a YYYYMMDD based format so the file names sort properly.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Proc format;
picture datetimeunderscore
low-high='%0d%b%Y_%0H_%0M_%0S' (datatype=datetime);

run;

%let StartTime1 = %sysfunc(datetime(), datetimeunderscore.);
%put starttime is:&amp;amp;starttime1.;&lt;/PRE&gt;
&lt;P&gt;Notes: do not use double quotes around the directives. Those % which are the directives for date, time and datetime pieces get confused with macro statements. The directives are case sensitive.%M is minutes 0 to 59, %m is month 1 to 12. The %H is a 24 hour clock hour. Read the documentation on the Format Picture statement for additional details options.&lt;/P&gt;
&lt;P&gt;The %0 means to insert a 0 so 1 hour displays as 01.&lt;/P&gt;</description>
      <pubDate>Tue, 30 Jan 2024 22:56:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-system-time-in-a-specific-format-quot-Hour-Minute/m-p/913692#M360097</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-01-30T22:56:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to create system time in a specific format "Hour_Minute_Second"?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-system-time-in-a-specific-format-quot-Hour-Minute/m-p/913699#M360101</link>
      <description>&lt;P&gt;You can use TRANSLATE() to replace the characters you don't want with something else.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But don't use date values in the style produced by the DATE format.&amp;nbsp; Strings like that will not sort properly&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also decide whether you want the time the program started, like you said.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or the time when you ran the DATETIME() function call, like the code you shared.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;1    * When SAS started ;
2    %let ts = %sysfunc(translate(%sysfunc(putn("&amp;amp;sysdate9:&amp;amp;systime"dt,e8601dt19.)),___,T:-));
3    %put &amp;amp;=ts;
TS=2024_01_30_18_56_00
4
5    * NOW ;
6    %let ts = %sysfunc(translate(%sysfunc(datetime(),e8601dt19.),___,T:-));
7    %put &amp;amp;=ts;
TS=2024_01_30_19_03_09

&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 31 Jan 2024 00:08:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-system-time-in-a-specific-format-quot-Hour-Minute/m-p/913699#M360101</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-01-31T00:08:46Z</dc:date>
    </item>
  </channel>
</rss>

