<?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: reformatting a datetime variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/reformatting-a-datetime-variable/m-p/680783#M205822</link>
    <description>&lt;P&gt;You can create a custom PICTURE format that will look exactly the way you want it to look. Here's the documentation:&amp;nbsp;&lt;A href="https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.4&amp;amp;docsetId=proc&amp;amp;docsetTarget=p0n990vq8gxca6n1vnsracr6jp2c.htm&amp;amp;locale=en#p0eubpiv9ngaocn1uatbigc5swi2"&gt;https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.4&amp;amp;docsetId=proc&amp;amp;docsetTarget=p0n990vq8gxca6n1vnsracr6jp2c.htm&amp;amp;locale=en#p0eubpiv9ngaocn1uatbigc5swi2&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And a small example:&amp;nbsp;&lt;A href="https://sasnrd.com/sas-date-datetime-proc-format-example/" target="_blank"&gt;https://sasnrd.com/sas-date-datetime-proc-format-example/&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 01 Sep 2020 17:52:38 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2020-09-01T17:52:38Z</dc:date>
    <item>
      <title>reformatting a datetime variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/reformatting-a-datetime-variable/m-p/680773#M205818</link>
      <description>&lt;P&gt;I've got a datetime variable called admit that is in the datetime16. format. Example: 31JUL20:23:59:35&lt;/P&gt;&lt;P&gt;But I hate that formatting when I'm trying to read the results of a PROC PRINT.&lt;/P&gt;&lt;P&gt;Here's how I'd like the above value to appear in my output:&amp;nbsp; &amp;nbsp;JUL/31/2020_23:59:35&lt;/P&gt;&lt;P&gt;Is there a way I can write a customized datetime format to do that?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Andrew&lt;/P&gt;</description>
      <pubDate>Tue, 01 Sep 2020 17:34:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/reformatting-a-datetime-variable/m-p/680773#M205818</guid>
      <dc:creator>DocMartin</dc:creator>
      <dc:date>2020-09-01T17:34:06Z</dc:date>
    </item>
    <item>
      <title>Re: reformatting a datetime variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/reformatting-a-datetime-variable/m-p/680783#M205822</link>
      <description>&lt;P&gt;You can create a custom PICTURE format that will look exactly the way you want it to look. Here's the documentation:&amp;nbsp;&lt;A href="https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.4&amp;amp;docsetId=proc&amp;amp;docsetTarget=p0n990vq8gxca6n1vnsracr6jp2c.htm&amp;amp;locale=en#p0eubpiv9ngaocn1uatbigc5swi2"&gt;https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.4&amp;amp;docsetId=proc&amp;amp;docsetTarget=p0n990vq8gxca6n1vnsracr6jp2c.htm&amp;amp;locale=en#p0eubpiv9ngaocn1uatbigc5swi2&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And a small example:&amp;nbsp;&lt;A href="https://sasnrd.com/sas-date-datetime-proc-format-example/" target="_blank"&gt;https://sasnrd.com/sas-date-datetime-proc-format-example/&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 01 Sep 2020 17:52:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/reformatting-a-datetime-variable/m-p/680783#M205822</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-09-01T17:52:38Z</dc:date>
    </item>
    <item>
      <title>Re: reformatting a datetime variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/reformatting-a-datetime-variable/m-p/680784#M205823</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/83350"&gt;@DocMartin&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I've got a datetime variable called admit that is in the datetime16. format. Example: 31JUL20:23:59:35&lt;/P&gt;
&lt;P&gt;But I hate that formatting when I'm trying to read the results of a PROC PRINT.&lt;/P&gt;
&lt;P&gt;Here's how I'd like the above value to appear in my output:&amp;nbsp; &amp;nbsp;JUL/31/2020_23:59:35&lt;/P&gt;
&lt;P&gt;Is there a way I can write a customized datetime format to do that?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Andrew&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;If your really want that appearance:&lt;/P&gt;
&lt;PRE&gt;proc format;
picture mydatetime
low-high='%3B/%0d/%Y_%H:%0m:%0s'  (datatype=datetime)
;
run;

data example;
   x= "31JUL20:23:59:35"dt;
   put x=mydatetime.;
run;&lt;/PRE&gt;
&lt;P&gt;You will have to make sure the format is available in any session you want to use it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The Picture statement is one of the few where single and double quotes make a difference. If you use double quotes in the picture then SAS will think the %(value) are macro related and not Picture statement date, datetime or time directives.&lt;/P&gt;</description>
      <pubDate>Tue, 01 Sep 2020 17:59:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/reformatting-a-datetime-variable/m-p/680784#M205823</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-09-01T17:59:40Z</dc:date>
    </item>
    <item>
      <title>Re: reformatting a datetime variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/reformatting-a-datetime-variable/m-p/680786#M205825</link>
      <description>&lt;P&gt;If you want something "quick and dirty," you can always do something like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%LET	Dt	=	%SYSFUNC(PUTN('31JUL20:23:59:35'dt, datetime19.));
%LET	Dt	=	%QSUBSTR(&amp;amp;DT,3,3)/%QSUBSTR(&amp;amp;DT,1,2)/%QSUBSTR(&amp;amp;Dt,6,4)_%QSUBSTR(&amp;amp;Dt,11,2):%QSUBSTR(&amp;amp;Dt,14,2):%QSUBSTR(&amp;amp;Dt,17,2);
%PUT	NOTE:  &amp;amp;=Dt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I some times will use something like that for a Title statement when it's a custom request and it's not something I see a lot of repeated use for.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jim&lt;/P&gt;</description>
      <pubDate>Tue, 01 Sep 2020 18:28:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/reformatting-a-datetime-variable/m-p/680786#M205825</guid>
      <dc:creator>jimbarbour</dc:creator>
      <dc:date>2020-09-01T18:28:43Z</dc:date>
    </item>
  </channel>
</rss>

