<?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: FileName with Date and Time in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/FileName-with-Date-and-Time/m-p/579489#M13456</link>
    <description>&lt;P&gt;Thank u so much for your comment. Its working good. Can you give me a sample to do the same using picture format if possible??&lt;/P&gt;</description>
    <pubDate>Tue, 06 Aug 2019 19:59:24 GMT</pubDate>
    <dc:creator>meenakshim</dc:creator>
    <dc:date>2019-08-06T19:59:24Z</dc:date>
    <item>
      <title>FileName with Date and Time</title>
      <link>https://communities.sas.com/t5/New-SAS-User/FileName-with-Date-and-Time/m-p/578096#M13296</link>
      <description>&lt;P&gt;I am trying to create a file from SAS with date and timestamp on as below,&lt;/P&gt;&lt;P&gt;NAME_201907241615A.TXT&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I could able to get the date in YYYYMMDD format using date() function with YYMMDDN8 format.&lt;/P&gt;&lt;P&gt;But i am finding difficult to get the time in 24 hr format. Or else if time is 9 AM , space is coming before 9 instead of 09.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So i tried this logic and it is working good as expected,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%let Time = %sysfunc(time(),time.) ;&lt;BR /&gt;%let Time_HH = %scan(&amp;amp;Time,1,:) ;&lt;BR /&gt;%let Time_MM = %scan(&amp;amp;Time,2,:) ;&lt;/P&gt;&lt;P&gt;HH=PUT(&amp;amp;TIME_HH,2.);&lt;BR /&gt;&lt;FONT color="#FF6600"&gt;if length(hh)&amp;lt;3 and '0'&amp;gt;= hh &amp;lt; '10' then hh=repeat('0',2-length(hh))||strip(hh);&amp;nbsp;&lt;/FONT&gt;&lt;BR /&gt;MM =PUT(&amp;amp;TIME_MM,2.);&lt;BR /&gt;&lt;FONT color="#FF6600"&gt;if length(mm)&amp;lt;3 and '0'&amp;gt;= mm &amp;lt; '10' then mm=repeat('0',2-length(mm))||strip(mm);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;var9="EDS"||"_"||"&amp;amp;VEN"||"_"||"&amp;amp;LOB"||"_"||"&amp;amp;TYP"||TRIM("_")||strip(%sysfunc(date(),YYMMDDN8.))||TRIM(HH)||TRIM(MM)||TRIM("A")||&amp;amp;VER;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The red highlighted portion i tried to get hour and minute as 2 digit (like 09), if the time is single digit.&lt;/P&gt;&lt;P&gt;I think there could be a straightforward approach , which i am missing. Is there is any other options to do this simply?Can we do this using picture clause in format?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Meenakshi&lt;/P&gt;</description>
      <pubDate>Wed, 31 Jul 2019 14:17:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/FileName-with-Date-and-Time/m-p/578096#M13296</guid>
      <dc:creator>meenakshim</dc:creator>
      <dc:date>2019-07-31T14:17:37Z</dc:date>
    </item>
    <item>
      <title>Re: FileName with Date and Time</title>
      <link>https://communities.sas.com/t5/New-SAS-User/FileName-with-Date-and-Time/m-p/578099#M13298</link>
      <description>&lt;P&gt;If you want to display numbers with leading zeros use the Z format.&lt;/P&gt;
&lt;PRE&gt;880   data _null_;
881     x=5;
882     put x Z2.;
883   run;

05
&lt;/PRE&gt;</description>
      <pubDate>Wed, 31 Jul 2019 14:24:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/FileName-with-Date-and-Time/m-p/578099#M13298</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-07-31T14:24:31Z</dc:date>
    </item>
    <item>
      <title>Re: FileName with Date and Time</title>
      <link>https://communities.sas.com/t5/New-SAS-User/FileName-with-Date-and-Time/m-p/578123#M13300</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let fileTimeStamp = %sysfunc(date(), yymmddn8.)%sysfunc(putc(%sysfunc(time(), b8601TM6.), $4.)) ;
%put &amp;amp;fileTimeStamp.;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;DIV class="sasSource"&gt;Results:&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;71 %let fileTime = %sysfunc(date(), yymmddn8.)%sysfunc(putc(%sysfunc(time(), b8601TM6.), $4.)) ;&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;72 %put &amp;amp;fileTime.;&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;&lt;FONT color="#FF6600"&gt;&lt;STRONG&gt;201907310938&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;&lt;FONT color="#FF6600"&gt;&lt;STRONG&gt;YYYYMMDDHHMM&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/254321"&gt;@meenakshim&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I am trying to create a file from SAS with date and timestamp on as below,&lt;/P&gt;
&lt;P&gt;NAME_201907241615A.TXT&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I could able to get the date in YYYYMMDD format using date() function with YYMMDDN8 format.&lt;/P&gt;
&lt;P&gt;But i am finding difficult to get the time in 24 hr format. Or else if time is 9 AM , space is coming before 9 instead of 09.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So i tried this logic and it is working good as expected,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%let Time = %sysfunc(time(),time.) ;&lt;BR /&gt;%let Time_HH = %scan(&amp;amp;Time,1,:) ;&lt;BR /&gt;%let Time_MM = %scan(&amp;amp;Time,2,:) ;&lt;/P&gt;
&lt;P&gt;HH=PUT(&amp;amp;TIME_HH,2.);&lt;BR /&gt;&lt;FONT color="#FF6600"&gt;if length(hh)&amp;lt;3 and '0'&amp;gt;= hh &amp;lt; '10' then hh=repeat('0',2-length(hh))||strip(hh);&amp;nbsp;&lt;/FONT&gt;&lt;BR /&gt;MM =PUT(&amp;amp;TIME_MM,2.);&lt;BR /&gt;&lt;FONT color="#FF6600"&gt;if length(mm)&amp;lt;3 and '0'&amp;gt;= mm &amp;lt; '10' then mm=repeat('0',2-length(mm))||strip(mm);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;var9="EDS"||"_"||"&amp;amp;VEN"||"_"||"&amp;amp;LOB"||"_"||"&amp;amp;TYP"||TRIM("_")||strip(%sysfunc(date(),YYMMDDN8.))||TRIM(HH)||TRIM(MM)||TRIM("A")||&amp;amp;VER;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The red highlighted portion i tried to get hour and minute as 2 digit (like 09), if the time is single digit.&lt;/P&gt;
&lt;P&gt;I think there could be a straightforward approach , which i am missing. Is there is any other options to do this simply?Can we do this using picture clause in format?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;Meenakshi&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;FONT color="#FF6600"&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;&amp;nbsp;&lt;/DIV&gt;</description>
      <pubDate>Wed, 31 Jul 2019 15:39:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/FileName-with-Date-and-Time/m-p/578123#M13300</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-07-31T15:39:24Z</dc:date>
    </item>
    <item>
      <title>Re: FileName with Date and Time</title>
      <link>https://communities.sas.com/t5/New-SAS-User/FileName-with-Date-and-Time/m-p/578156#M13304</link>
      <description>Why not make a picture format?</description>
      <pubDate>Wed, 31 Jul 2019 17:34:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/FileName-with-Date-and-Time/m-p/578156#M13304</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2019-07-31T17:34:26Z</dc:date>
    </item>
    <item>
      <title>Re: FileName with Date and Time</title>
      <link>https://communities.sas.com/t5/New-SAS-User/FileName-with-Date-and-Time/m-p/578159#M13305</link>
      <description>Picture formats for datetimes aren't honoured in some graphics plot and/or SAS Viya for custom formats. So using out of the box options means it'll work out of the box in most versions of SAS. But picture format is definitely doable and a good approach. It's also more code - technically &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 31 Jul 2019 17:53:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/FileName-with-Date-and-Time/m-p/578159#M13305</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-07-31T17:53:53Z</dc:date>
    </item>
    <item>
      <title>Re: FileName with Date and Time</title>
      <link>https://communities.sas.com/t5/New-SAS-User/FileName-with-Date-and-Time/m-p/578165#M13308</link>
      <description>What does graphics or Viya have to do with making a file name with a time stamp?</description>
      <pubDate>Wed, 31 Jul 2019 18:07:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/FileName-with-Date-and-Time/m-p/578165#M13308</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2019-07-31T18:07:48Z</dc:date>
    </item>
    <item>
      <title>Re: FileName with Date and Time</title>
      <link>https://communities.sas.com/t5/New-SAS-User/FileName-with-Date-and-Time/m-p/578166#M13309</link>
      <description>&lt;P&gt;Nothing, it's just a style of defensive programming that means that its easier to port programs.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There are likely at least five different ways this could be solved, that's just one option that seems to align with what the user understand and wants.&lt;/P&gt;</description>
      <pubDate>Wed, 31 Jul 2019 18:10:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/FileName-with-Date-and-Time/m-p/578166#M13309</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-07-31T18:10:15Z</dc:date>
    </item>
    <item>
      <title>Re: FileName with Date and Time</title>
      <link>https://communities.sas.com/t5/New-SAS-User/FileName-with-Date-and-Time/m-p/579489#M13456</link>
      <description>&lt;P&gt;Thank u so much for your comment. Its working good. Can you give me a sample to do the same using picture format if possible??&lt;/P&gt;</description>
      <pubDate>Tue, 06 Aug 2019 19:59:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/FileName-with-Date-and-Time/m-p/579489#M13456</guid>
      <dc:creator>meenakshim</dc:creator>
      <dc:date>2019-08-06T19:59:24Z</dc:date>
    </item>
    <item>
      <title>Re: FileName with Date and Time</title>
      <link>https://communities.sas.com/t5/New-SAS-User/FileName-with-Date-and-Time/m-p/579496#M13457</link>
      <description>&lt;P&gt;Here's a close option:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format; 
  picture  datetimeStamp
          low-high='%Y%0m%0d%0H%0M%p' (datatype=datetime);
run;

%put %sysfunc(datetime(), datetimeStamp.);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You can play around with the date directives to customize it if needed.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Literals are documented here:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://go.documentation.sas.com/?docsetId=proc&amp;amp;docsetTarget=p0n990vq8gxca6n1vnsracr6jp2c.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en#p0eubpiv9ngaocn1uatbigc5swi2"&gt;https://go.documentation.sas.com/?docsetId=proc&amp;amp;docsetTarget=p0n990vq8gxca6n1vnsracr6jp2c.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en#p0eubpiv9ngaocn1uatbigc5swi2&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Aug 2019 20:40:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/FileName-with-Date-and-Time/m-p/579496#M13457</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-08-06T20:40:52Z</dc:date>
    </item>
  </channel>
</rss>

