<?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 How to combine datetime type date with a datetime type time into a long date in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-combine-datetime-type-date-with-a-datetime-type-time-into/m-p/478110#M123242</link>
    <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hello all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am new to SAS and facing an issue in combining a datetime type date [&lt;SPAN&gt;XEDDAT&lt;/SPAN&gt;] (e.g. 07JUN15:00:00:00) with a datetime type time [&lt;SPAN&gt;XEDTIM&lt;/SPAN&gt;] (01JAN01:14:15:00) into a long date like "&lt;SPAN&gt;07JUN2015:14:15:00&lt;/SPAN&gt;" that I can use to calculate time interval.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But when I wrote&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;newday&amp;nbsp;= XEDDAT + XEDTIM;&lt;BR /&gt;format &lt;SPAN&gt;newday&lt;/SPAN&gt; datetime20.;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;the result date ended as "07JUN2056:14:15:00" instead of "07JUN2015:14:15:00".&lt;/P&gt;&lt;P&gt;This might be caused by the SAS cutoff date? any help would be greatly appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Urgently waiting and thank you so much for your reply!!!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;zimcom&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 14 Jul 2018 14:35:41 GMT</pubDate>
    <dc:creator>zimcom</dc:creator>
    <dc:date>2018-07-14T14:35:41Z</dc:date>
    <item>
      <title>How to combine datetime type date with a datetime type time into a long date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-combine-datetime-type-date-with-a-datetime-type-time-into/m-p/478110#M123242</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hello all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am new to SAS and facing an issue in combining a datetime type date [&lt;SPAN&gt;XEDDAT&lt;/SPAN&gt;] (e.g. 07JUN15:00:00:00) with a datetime type time [&lt;SPAN&gt;XEDTIM&lt;/SPAN&gt;] (01JAN01:14:15:00) into a long date like "&lt;SPAN&gt;07JUN2015:14:15:00&lt;/SPAN&gt;" that I can use to calculate time interval.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But when I wrote&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;newday&amp;nbsp;= XEDDAT + XEDTIM;&lt;BR /&gt;format &lt;SPAN&gt;newday&lt;/SPAN&gt; datetime20.;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;the result date ended as "07JUN2056:14:15:00" instead of "07JUN2015:14:15:00".&lt;/P&gt;&lt;P&gt;This might be caused by the SAS cutoff date? any help would be greatly appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Urgently waiting and thank you so much for your reply!!!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;zimcom&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 14 Jul 2018 14:35:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-combine-datetime-type-date-with-a-datetime-type-time-into/m-p/478110#M123242</guid>
      <dc:creator>zimcom</dc:creator>
      <dc:date>2018-07-14T14:35:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to combine datetime type date with a datetime type time into a long date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-combine-datetime-type-date-with-a-datetime-type-time-into/m-p/478114#M123244</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
k='07JUN15:00:00:00'dt;
k2='01JAN01:14:15:00'dt;
k3=k+timepart(k2);
format k: datetime20.;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 14 Jul 2018 14:57:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-combine-datetime-type-date-with-a-datetime-type-time-into/m-p/478114#M123244</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-07-14T14:57:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to combine datetime type date with a datetime type time into a long date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-combine-datetime-type-date-with-a-datetime-type-time-into/m-p/478115#M123245</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/219549"&gt;@zimcom&lt;/a&gt;&amp;nbsp;Your approach is partially right but you should extract the time component from your second date variable before you add that to your other datetime var&lt;/P&gt;</description>
      <pubDate>Sat, 14 Jul 2018 15:01:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-combine-datetime-type-date-with-a-datetime-type-time-into/m-p/478115#M123245</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-07-14T15:01:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to combine datetime type date with a datetime type time into a long date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-combine-datetime-type-date-with-a-datetime-type-time-into/m-p/478116#M123246</link>
      <description>&lt;P&gt;You can definitely add a TIME value to a DATETIME value to calculate a new DATETIME value.&amp;nbsp; Both values are counts of seconds.&amp;nbsp; A TIME value is the number of seconds since midnight.&amp;nbsp; A DATETIME values is the number of seconds since midnight of 1960.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But your second variable is NOT a time value. Time values are not associated with any particular calendar day.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can use the TIMEPART() function to extract just the time of day part of the value (and throw away the calendar day part).&amp;nbsp; You can also use the DATEPART() function to generate a DATE value (number of days since 1960) from a DATETIME value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
  XEDDAT = '07JUN2015:00:00:00'dt ;
  XEDTIM = '01JAN2001:14:15:00'dt ;

  XED_DATE = datepart(xeddat);
  XED_TIME = timepart(xedtim);

  XED_DATETIME = dhms(xed_date,0,0,xed_time);
  XED_DATETIME2 = xeddat + timepart(xedtim);

  format xeddat xedtim xed_datetime: datetime20. xed_date date9. xed_time time8. ;
  put / 'FORMATTED VALUES' / (_all_) (=/);
  put / 'RAW VALUES' / (_all_) (=comma32./);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;FORMATTED VALUES

XEDDAT=07JUN2015:00:00:00
XEDTIM=01JAN2001:14:15:00
XED_DATE=07JUN2015
XED_TIME=14:15:00
XED_DATETIME=07JUN2015:14:15:00
XED_DATETIME2=07JUN2015:14:15:00

RAW VALUES

XEDDAT=1,749,254,400
XEDTIM=1,293,977,700
XED_DATE=20,246
XED_TIME=51,300
XED_DATETIME=1,749,305,700
XED_DATETIME2=1,749,305,700&lt;/PRE&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>Sat, 14 Jul 2018 15:22:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-combine-datetime-type-date-with-a-datetime-type-time-into/m-p/478116#M123246</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-07-14T15:22:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to combine datetime type date with a datetime type time into a long date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-combine-datetime-type-date-with-a-datetime-type-time-into/m-p/478129#M123251</link>
      <description>&lt;P&gt;Hi Tom,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I really appreciated your detailed explanation and help.&lt;/P&gt;&lt;P&gt;Thank you so much!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;zimcom&lt;/P&gt;</description>
      <pubDate>Sat, 14 Jul 2018 18:02:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-combine-datetime-type-date-with-a-datetime-type-time-into/m-p/478129#M123251</guid>
      <dc:creator>zimcom</dc:creator>
      <dc:date>2018-07-14T18:02:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to combine datetime type date with a datetime type time into a long date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-combine-datetime-type-date-with-a-datetime-type-time-into/m-p/478130#M123252</link>
      <description>I really appreciated your help.&lt;BR /&gt;Thank you so much!</description>
      <pubDate>Sat, 14 Jul 2018 18:03:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-combine-datetime-type-date-with-a-datetime-type-time-into/m-p/478130#M123252</guid>
      <dc:creator>zimcom</dc:creator>
      <dc:date>2018-07-14T18:03:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to combine datetime type date with a datetime type time into a long date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-combine-datetime-type-date-with-a-datetime-type-time-into/m-p/478134#M123254</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/219549"&gt;@zimcom&lt;/a&gt;&amp;nbsp;You are welcome. Have a great weekend!&lt;/P&gt;</description>
      <pubDate>Sat, 14 Jul 2018 18:35:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-combine-datetime-type-date-with-a-datetime-type-time-into/m-p/478134#M123254</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-07-14T18:35:40Z</dc:date>
    </item>
  </channel>
</rss>

