<?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: To make SAS show human readable datetime if the datetime variable is unformatted in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/To-make-SAS-show-human-readable-datetime-if-the-datetime/m-p/93962#M19801</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you for the suggestions. &lt;/P&gt;&lt;P&gt;My data is imported from a Stata file and has the datetime variable stored as a number (type: double, format: %tc). After importing, in the temporary SAS dataset, this variable shows up as&amp;nbsp; e.g. 1.1863584E12 which is nothing but 22aug2000 11:00:00. as it shows in the Stata dataset when I open it in the table mode.&lt;/P&gt;&lt;P&gt;Do I still need to convert it to datetime using DHMS and then apply the datetimew.d format?&lt;/P&gt;&lt;P&gt;Thanks a bunch. This is really simple, I know but I have just started.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 26 Sep 2013 17:32:25 GMT</pubDate>
    <dc:creator>saurabhc</dc:creator>
    <dc:date>2013-09-26T17:32:25Z</dc:date>
    <item>
      <title>To make SAS show human readable datetime if the datetime variable is unformatted</title>
      <link>https://communities.sas.com/t5/SAS-Programming/To-make-SAS-show-human-readable-datetime-if-the-datetime/m-p/93959#M19798</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;BR /&gt;I have all numerical values like how SAS counts them in days since Jan 1, 1960. I need SAS to show them to me in the format DDMMMYYhh:mm:ss. I tried the following but to no avail&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt;data work.one;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set work.two;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; format datetimevar DATETIME16.0;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 10pt;"&gt;What am I missing?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 10pt;"&gt;Thank you.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Sep 2013 22:05:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/To-make-SAS-show-human-readable-datetime-if-the-datetime/m-p/93959#M19798</guid>
      <dc:creator>saurabhc</dc:creator>
      <dc:date>2013-09-25T22:05:07Z</dc:date>
    </item>
    <item>
      <title>Re: To make SAS show human readable datetime if the datetime variable is unformatted</title>
      <link>https://communities.sas.com/t5/SAS-Programming/To-make-SAS-show-human-readable-datetime-if-the-datetime/m-p/93960#M19799</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;datetimes are seconds from jan 1, 1960 not days. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;That looks like the default format, so I'm guessing somethings wrong with your dates, eg dates, not datetime or character variables instead of number.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This works as expected:&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;SPAN style="color: #011993;"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/SPAN&gt; one;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 10pt;"&gt;var1=dhms(&lt;SPAN style="color: #009193;"&gt;&lt;STRONG&gt;18754&lt;/STRONG&gt;&lt;/SPAN&gt;, &lt;SPAN style="color: #009193;"&gt;&lt;STRONG&gt;0&lt;/STRONG&gt;&lt;/SPAN&gt;, &lt;SPAN style="color: #009193;"&gt;&lt;STRONG&gt;0&lt;/STRONG&gt;&lt;/SPAN&gt;, &lt;SPAN style="color: #009193;"&gt;&lt;STRONG&gt;0&lt;/STRONG&gt;&lt;/SPAN&gt;);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 10pt;"&gt;var2=var1;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New'; color: #009193;"&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;SPAN style="color: #0433ff;"&gt;format&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt; var2 &lt;/SPAN&gt;datetime.&lt;SPAN style="color: #000000;"&gt;;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New'; color: #011993;"&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;SPAN style="color: #000000;"&gt;;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New'; color: #011993;"&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;SPAN style="color: #000000;"&gt; &lt;/SPAN&gt;&lt;STRONG&gt;print&lt;/STRONG&gt;&lt;SPAN style="color: #000000;"&gt;;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New'; color: #011993;"&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;SPAN style="color: #000000;"&gt;;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Sep 2013 23:22:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/To-make-SAS-show-human-readable-datetime-if-the-datetime/m-p/93960#M19799</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2013-09-25T23:22:09Z</dc:date>
    </item>
    <item>
      <title>Re: To make SAS show human readable datetime if the datetime variable is unformatted</title>
      <link>https://communities.sas.com/t5/SAS-Programming/To-make-SAS-show-human-readable-datetime-if-the-datetime/m-p/93961#M19800</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;As Reeza suggests, your data must be a datetime value to use the DATETIMEw.d format.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If your data is a date value (not datetime), you will have to convert it to a datetime value (e.g. via the DHMS function as Reeza suggests) if you want to apply the DATETIMEw.d format.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If data is a date value, and you just want to display the date in human-readable form and you aren't concerned about hours/minutes/seconds, then use a format like DATE9.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 26 Sep 2013 01:36:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/To-make-SAS-show-human-readable-datetime-if-the-datetime/m-p/93961#M19800</guid>
      <dc:creator>Fugue</dc:creator>
      <dc:date>2013-09-26T01:36:52Z</dc:date>
    </item>
    <item>
      <title>Re: To make SAS show human readable datetime if the datetime variable is unformatted</title>
      <link>https://communities.sas.com/t5/SAS-Programming/To-make-SAS-show-human-readable-datetime-if-the-datetime/m-p/93962#M19801</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you for the suggestions. &lt;/P&gt;&lt;P&gt;My data is imported from a Stata file and has the datetime variable stored as a number (type: double, format: %tc). After importing, in the temporary SAS dataset, this variable shows up as&amp;nbsp; e.g. 1.1863584E12 which is nothing but 22aug2000 11:00:00. as it shows in the Stata dataset when I open it in the table mode.&lt;/P&gt;&lt;P&gt;Do I still need to convert it to datetime using DHMS and then apply the datetimew.d format?&lt;/P&gt;&lt;P&gt;Thanks a bunch. This is really simple, I know but I have just started.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 26 Sep 2013 17:32:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/To-make-SAS-show-human-readable-datetime-if-the-datetime/m-p/93962#M19801</guid>
      <dc:creator>saurabhc</dc:creator>
      <dc:date>2013-09-26T17:32:25Z</dc:date>
    </item>
    <item>
      <title>Re: To make SAS show human readable datetime if the datetime variable is unformatted</title>
      <link>https://communities.sas.com/t5/SAS-Programming/To-make-SAS-show-human-readable-datetime-if-the-datetime/m-p/93963#M19802</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;From what I read about STATA it seems to be saying the %tc is for numbers stored in Milliseconds.&amp;nbsp; Try dividing the numbers you see in your SAS variable by 1000 and then apply a DATETIME. type format.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Your example doesn't look right as when I try that number I get a date in 1997.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;26&amp;nbsp;&amp;nbsp; data _null_;&lt;/P&gt;&lt;P&gt;27&amp;nbsp;&amp;nbsp;&amp;nbsp; x = '22aug2000:11:00:00'dt;&lt;/P&gt;&lt;P&gt;28&amp;nbsp;&amp;nbsp;&amp;nbsp; put x= x= datetime19. ;&lt;/P&gt;&lt;P&gt;29&amp;nbsp;&amp;nbsp;&amp;nbsp; y = 1.1863584E12 ;&lt;/P&gt;&lt;P&gt;30&amp;nbsp;&amp;nbsp;&amp;nbsp; put y= ;&lt;/P&gt;&lt;P&gt;31&amp;nbsp;&amp;nbsp;&amp;nbsp; x = y/1000 ;&lt;/P&gt;&lt;P&gt;32&amp;nbsp;&amp;nbsp;&amp;nbsp; put x= x= datetime19. ;&lt;/P&gt;&lt;P&gt;33&amp;nbsp;&amp;nbsp; run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;x=1282561200 x=22AUG2000:11:00:00&lt;/P&gt;&lt;P&gt;y=1.1863584E12&lt;/P&gt;&lt;P&gt;x=1186358400 x=05AUG1997:00:00:099&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 26 Sep 2013 17:45:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/To-make-SAS-show-human-readable-datetime-if-the-datetime/m-p/93963#M19802</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2013-09-26T17:45:23Z</dc:date>
    </item>
    <item>
      <title>Re: To make SAS show human readable datetime if the datetime variable is unformatted</title>
      <link>https://communities.sas.com/t5/SAS-Programming/To-make-SAS-show-human-readable-datetime-if-the-datetime/m-p/93964#M19803</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you, Tom, Fugue and Reeza.&lt;/P&gt;&lt;P&gt;The last solution totally worked.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 26 Sep 2013 18:08:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/To-make-SAS-show-human-readable-datetime-if-the-datetime/m-p/93964#M19803</guid>
      <dc:creator>saurabhc</dc:creator>
      <dc:date>2013-09-26T18:08:29Z</dc:date>
    </item>
  </channel>
</rss>

