<?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 Datetime Field DHMS weird behavior in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Datetime-Field-DHMS-weird-behavior/m-p/201837#M50412</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;SAS 9.2&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a date field &lt;STRONG&gt;appointment_date &lt;/STRONG&gt;and it shows '10Jan2014'. It is a date field and not text field.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And then I run this SAS code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data NCA_OAOS3x;&lt;/P&gt;&lt;P&gt;set NCA_OAOS3 (where=(oaos_case_no='S140106-5'));&lt;/P&gt;&lt;P&gt;appt_date_timex=dhms(appointment_date,12,0,0);&lt;/P&gt;&lt;P&gt;format appt_date_timex datetime.;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It returns 11JAN14:02:00:00&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And if I run this SAS code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data NCA_OAOS3x;&lt;/P&gt;&lt;P&gt;set NCA_OAOS3 (where=(oaos_case_no='S140106-5'));&lt;/P&gt;&lt;P&gt;appt_date_timex=dhms(appointment_date,&lt;SPAN style="color: #ff0000;"&gt;&lt;STRONG&gt;0&lt;/STRONG&gt;&lt;/SPAN&gt;,0,0);&lt;/P&gt;&lt;P&gt;format appt_date_timex datetime.;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It returns 10JAN14:14:00:00&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can anyone explain why the hour component is not returning as expected? There seems to be hour component in the date field. Date field is actually '10Jan14:14:00:00'&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 10 Jun 2015 06:43:51 GMT</pubDate>
    <dc:creator>hellind</dc:creator>
    <dc:date>2015-06-10T06:43:51Z</dc:date>
    <item>
      <title>Datetime Field DHMS weird behavior</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Datetime-Field-DHMS-weird-behavior/m-p/201837#M50412</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;SAS 9.2&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a date field &lt;STRONG&gt;appointment_date &lt;/STRONG&gt;and it shows '10Jan2014'. It is a date field and not text field.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And then I run this SAS code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data NCA_OAOS3x;&lt;/P&gt;&lt;P&gt;set NCA_OAOS3 (where=(oaos_case_no='S140106-5'));&lt;/P&gt;&lt;P&gt;appt_date_timex=dhms(appointment_date,12,0,0);&lt;/P&gt;&lt;P&gt;format appt_date_timex datetime.;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It returns 11JAN14:02:00:00&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And if I run this SAS code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data NCA_OAOS3x;&lt;/P&gt;&lt;P&gt;set NCA_OAOS3 (where=(oaos_case_no='S140106-5'));&lt;/P&gt;&lt;P&gt;appt_date_timex=dhms(appointment_date,&lt;SPAN style="color: #ff0000;"&gt;&lt;STRONG&gt;0&lt;/STRONG&gt;&lt;/SPAN&gt;,0,0);&lt;/P&gt;&lt;P&gt;format appt_date_timex datetime.;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It returns 10JAN14:14:00:00&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can anyone explain why the hour component is not returning as expected? There seems to be hour component in the date field. Date field is actually '10Jan14:14:00:00'&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Jun 2015 06:43:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Datetime-Field-DHMS-weird-behavior/m-p/201837#M50412</guid>
      <dc:creator>hellind</dc:creator>
      <dc:date>2015-06-10T06:43:51Z</dc:date>
    </item>
    <item>
      <title>Re: Datetime Field DHMS weird behavior</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Datetime-Field-DHMS-weird-behavior/m-p/201838#M50413</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Provide a numeric, not date formatted value of your variable. &lt;BR /&gt;You might get this behavior if there are some decimals floating around.&lt;/P&gt;&lt;P&gt;If this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;appt_date_timex=dhms(floor(appointment_date),12,0,0);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;fixes the problem that was the likely cause.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Jun 2015 15:44:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Datetime-Field-DHMS-weird-behavior/m-p/201838#M50413</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2015-06-10T15:44:29Z</dc:date>
    </item>
    <item>
      <title>Re: Datetime Field DHMS weird behavior</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Datetime-Field-DHMS-weird-behavior/m-p/201839#M50414</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;ballardw,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks, it worked using floor. But why would there be a decimal in a date statement? Anyway it worked.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Jun 2015 11:15:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Datetime-Field-DHMS-weird-behavior/m-p/201839#M50414</guid>
      <dc:creator>hellind</dc:creator>
      <dc:date>2015-06-11T11:15:23Z</dc:date>
    </item>
    <item>
      <title>Re: Datetime Field DHMS weird behavior</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Datetime-Field-DHMS-weird-behavior/m-p/201840#M50415</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I would go back in your processes. Somebody may have converted hours to fraction of a day for another purpose. OR used a year to days conversion multiplying by 356.25 somewhere. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Jun 2015 16:32:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Datetime-Field-DHMS-weird-behavior/m-p/201840#M50415</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2015-06-11T16:32:05Z</dc:date>
    </item>
    <item>
      <title>Re: Datetime Field DHMS weird behavior</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Datetime-Field-DHMS-weird-behavior/m-p/201841#M50416</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I imported the data from an excel file. And in excel I can see 10-Jan-2014 in formatted. The underlying in excel &lt;STRONG&gt;could&lt;/STRONG&gt; be having decimal.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Lesson learnt: It is always safe to floor the date field then. Among a dataset of 10,000 rows, only a few of them had decimal and I was not aware of it unless my user feedback to me.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I thought the whole point of a date field is not to have any time component.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 12 Jun 2015 03:19:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Datetime-Field-DHMS-weird-behavior/m-p/201841#M50416</guid>
      <dc:creator>hellind</dc:creator>
      <dc:date>2015-06-12T03:19:06Z</dc:date>
    </item>
  </channel>
</rss>

