<?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: Convert Datetime to ddMONyyyybhh:mm:ss format in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Convert-Datetime-to-ddMONyyyybhh-mm-ss-format/m-p/234157#M42802</link>
    <description>Create a user defined format with the datetime "directives" (find that word in the documentation of PROC FORMAT)</description>
    <pubDate>Wed, 11 Nov 2015 08:34:43 GMT</pubDate>
    <dc:creator>Peter_C</dc:creator>
    <dc:date>2015-11-11T08:34:43Z</dc:date>
    <item>
      <title>Convert Datetime to ddMONyyyybhh:mm:ss format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-Datetime-to-ddMONyyyybhh-mm-ss-format/m-p/234123#M42786</link>
      <description>&lt;P&gt;Hi, I need to convert the current datetime into ddMONyyyybhh:mm:ss format.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For example - if the current time is - 11/10/2015 04:36:12&lt;/P&gt;
&lt;P&gt;expected result - 10NOV2015 04:36:12&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Tried the below, but need the&amp;nbsp;blank space&amp;nbsp;between year and hour, Please help me..&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt; test=put(datetime(),&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;datetime19.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Nov 2015 21:40:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-Datetime-to-ddMONyyyybhh-mm-ss-format/m-p/234123#M42786</guid>
      <dc:creator>sasbeginner_us</dc:creator>
      <dc:date>2015-11-10T21:40:39Z</dc:date>
    </item>
    <item>
      <title>Re: Convert Datetime to ddMONyyyybhh:mm:ss format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-Datetime-to-ddMONyyyybhh-mm-ss-format/m-p/234130#M42790</link>
      <description>&lt;P&gt;There are various ways to do this. Perhaps one of the simplest is to add the following statement after your correct assigment statement:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;substr(test,11,1)=' ';&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;As you may have noticed, format datetime19. creates a leading blank. To get rid of that, you could do this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;test=left(put(datetime(),datetime19.));
substr(test,10,1)=' ';
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;test=put(datetime(),datetime19.-l);
substr(test,10,1)=' ';&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Nov 2015 22:17:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-Datetime-to-ddMONyyyybhh-mm-ss-format/m-p/234130#M42790</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2015-11-10T22:17:39Z</dc:date>
    </item>
    <item>
      <title>Re: Convert Datetime to ddMONyyyybhh:mm:ss format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-Datetime-to-ddMONyyyybhh-mm-ss-format/m-p/234142#M42796</link>
      <description>&lt;P&gt;data _null_;&lt;BR /&gt;date="11/10/2015 4:36:12";&lt;BR /&gt;_date=input(date,mdyampm19.);&lt;BR /&gt;format _date datetime19.;&lt;BR /&gt;put _all_;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Nov 2015 23:15:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-Datetime-to-ddMONyyyybhh-mm-ss-format/m-p/234142#M42796</guid>
      <dc:creator>slchen</dc:creator>
      <dc:date>2015-11-10T23:15:24Z</dc:date>
    </item>
    <item>
      <title>Re: Convert Datetime to ddMONyyyybhh:mm:ss format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-Datetime-to-ddMONyyyybhh-mm-ss-format/m-p/234157#M42802</link>
      <description>Create a user defined format with the datetime "directives" (find that word in the documentation of PROC FORMAT)</description>
      <pubDate>Wed, 11 Nov 2015 08:34:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-Datetime-to-ddMONyyyybhh-mm-ss-format/m-p/234157#M42802</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2015-11-11T08:34:43Z</dc:date>
    </item>
    <item>
      <title>Re: Convert Datetime to ddMONyyyybhh:mm:ss format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-Datetime-to-ddMONyyyybhh-mm-ss-format/m-p/234161#M42804</link>
      <description>&lt;P&gt;Well, you have seen some solutions above, i.e. convert it to text, use an inbuilt format, or create your own. &amp;nbsp;I would ask why you want to do this, what is the purpose of it? &amp;nbsp;If you go with the text variety, then sorting becomes an issue, and you lose the ability to do simple maths on the variable. &amp;nbsp;If you create your own format, then a programmer picking your code up has to look at that format to see what it does (assuming there is no bitness issue on the catalog). &amp;nbsp;Whereas just using the base SAS dates has none of the above issues? &amp;nbsp;Now if its for a report your creating you could hybridise, have a character version and a numeric version, and only display the character one, whilst using the numeric for other processing. &amp;nbsp;Or you could change the report format. &amp;nbsp;Personally I tend to do both of these. &amp;nbsp;In the underlying dataset I would have variables for the necessary calculations, processing, general a date value, and a time value, but sometimes a date/time value. &amp;nbsp;Then there would also be a character version. &amp;nbsp;The reason is that dates have to be complete dates for them to be valid, i.e. day/mon/yr all present and right, but if you have partial dates you may want to display the partials, but not perform calculations, e.g. date=., time="01:00"t; datec="01-2012"; timec="01:00"; datetimec="2012-01---T01:00:00"&lt;/P&gt;
&lt;P&gt;You will see in this example I can't do date transformations directyl as date is missing, so would have imputation rules, but I can still do time calculations, and display the data as it is entered or in numeric format. &amp;nbsp;More flexibility in your data means less coding overall.&lt;/P&gt;</description>
      <pubDate>Wed, 11 Nov 2015 09:24:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-Datetime-to-ddMONyyyybhh-mm-ss-format/m-p/234161#M42804</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2015-11-11T09:24:33Z</dc:date>
    </item>
    <item>
      <title>Re: Convert Datetime to ddMONyyyybhh:mm:ss format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-Datetime-to-ddMONyyyybhh-mm-ss-format/m-p/234182#M42806</link>
      <description>RW9&lt;BR /&gt;I have exactly this need:&lt;BR /&gt;because so much data is passed to and "managed" in excel&lt;BR /&gt;DATETIME. formatted cells remain as strings.&lt;BR /&gt;With my userformat XLDATE. these values are automatically recognised by the excel importer.&lt;BR /&gt;proc format ;&lt;BR /&gt;picture XLDATE (round default= 19 )&lt;BR /&gt;other = '%0d%b%0Y %0H:%0M:%0S' (datatype= datetime );&lt;BR /&gt;run ;&lt;BR /&gt;&lt;BR /&gt;The only weaknesses with this are:&lt;BR /&gt;although I requested ROUND - it does not take effect&lt;BR /&gt;and there appears to be no "datetime directive" for decimal places of a second. When these become real issues I just put up with using formulas in excel to derive the timestamp value from a datetime21.2 string.&lt;BR /&gt;</description>
      <pubDate>Wed, 11 Nov 2015 13:46:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-Datetime-to-ddMONyyyybhh-mm-ss-format/m-p/234182#M42806</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2015-11-11T13:46:34Z</dc:date>
    </item>
    <item>
      <title>Re: Convert Datetime to ddMONyyyybhh:mm:ss format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-Datetime-to-ddMONyyyybhh-mm-ss-format/m-p/234487#M42881</link>
      <description>&lt;P&gt;thank u all&amp;nbsp;for the repsonse. Used the substr and it is working.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My understanding is that substr will extract partial text,&amp;nbsp;Could you please explain how it works in this case&amp;nbsp;?&lt;/P&gt;</description>
      <pubDate>Thu, 12 Nov 2015 20:59:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-Datetime-to-ddMONyyyybhh-mm-ss-format/m-p/234487#M42881</guid>
      <dc:creator>sasbeginner_us</dc:creator>
      <dc:date>2015-11-12T20:59:35Z</dc:date>
    </item>
    <item>
      <title>Re: Convert Datetime to ddMONyyyybhh:mm:ss format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-Datetime-to-ddMONyyyybhh-mm-ss-format/m-p/234488#M42882</link>
      <description>Thank you all, I used the substr and it is working. My understanding is that substr will extract partial text, Could you pls explain how the subtr works in this case ?</description>
      <pubDate>Thu, 12 Nov 2015 21:03:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-Datetime-to-ddMONyyyybhh-mm-ss-format/m-p/234488#M42882</guid>
      <dc:creator>sasbeginner_us</dc:creator>
      <dc:date>2015-11-12T21:03:04Z</dc:date>
    </item>
    <item>
      <title>Re: Convert Datetime to ddMONyyyybhh:mm:ss format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-Datetime-to-ddMONyyyybhh-mm-ss-format/m-p/234490#M42884</link>
      <description>&lt;P&gt;Thank you for liking and accepting my solution.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There are two different flavors of the SUBSTR function: If it is used to the right of an equals sign, it returns a substring. Left of the equals sign, however, it replaces&amp;nbsp;character value contents. (See the two separate entries for SUBSTR in the online help for more details.) So, in our case it was used to overwrite the first colon in the datetime string with a blank.&lt;/P&gt;</description>
      <pubDate>Thu, 12 Nov 2015 21:09:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-Datetime-to-ddMONyyyybhh-mm-ss-format/m-p/234490#M42884</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2015-11-12T21:09:24Z</dc:date>
    </item>
  </channel>
</rss>

