<?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: combine SAS date+SAS time to a new date_time field in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/combine-SAS-date-SAS-time-to-a-new-date-time-field/m-p/793721#M254437</link>
    <description>&lt;P&gt;No need to do all those character functions &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data have ;
format SAS_date date9.;
input SAS_date : date9. num_time;
cards;
'19JAN2021'd 101602
'13AUG2020'd 164500
;
Run;

data want;
   set have;
   dt = dhms(SAS_date, 0, 0, input(put(num_time, 6.), hhmmss6.));
   format dt datetime20.;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 01 Feb 2022 10:39:05 GMT</pubDate>
    <dc:creator>PeterClemmensen</dc:creator>
    <dc:date>2022-02-01T10:39:05Z</dc:date>
    <item>
      <title>combine SAS date+SAS time to a new date_time field</title>
      <link>https://communities.sas.com/t5/SAS-Programming/combine-SAS-date-SAS-time-to-a-new-date-time-field/m-p/793719#M254436</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;I want to create a new column called SAS_date_time with format of date time.&lt;/P&gt;
&lt;P&gt;What is the way to combine the date+time fields together?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data have ;
format SAS_date date9.;
input SAS_date : date9. num_time;
cards;
'19JAN2021'd 101602
'13AUG2020'd 164500
;
Run;

Data have2;
SET have;
string1 = put(num_time,z6.);
string2 = catx(":",substr(string1,1,2),substr(string1,3,2),substr(string1,5,2));
SAS_time = input(string2,time8.);
format SAS_time time8.;
KEEP  SAS_date  SAS_time;
Run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 01 Feb 2022 10:33:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/combine-SAS-date-SAS-time-to-a-new-date-time-field/m-p/793719#M254436</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2022-02-01T10:33:02Z</dc:date>
    </item>
    <item>
      <title>Re: combine SAS date+SAS time to a new date_time field</title>
      <link>https://communities.sas.com/t5/SAS-Programming/combine-SAS-date-SAS-time-to-a-new-date-time-field/m-p/793721#M254437</link>
      <description>&lt;P&gt;No need to do all those character functions &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data have ;
format SAS_date date9.;
input SAS_date : date9. num_time;
cards;
'19JAN2021'd 101602
'13AUG2020'd 164500
;
Run;

data want;
   set have;
   dt = dhms(SAS_date, 0, 0, input(put(num_time, 6.), hhmmss6.));
   format dt datetime20.;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 01 Feb 2022 10:39:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/combine-SAS-date-SAS-time-to-a-new-date-time-field/m-p/793721#M254437</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2022-02-01T10:39:05Z</dc:date>
    </item>
    <item>
      <title>Re: combine SAS date+SAS time to a new date_time field</title>
      <link>https://communities.sas.com/t5/SAS-Programming/combine-SAS-date-SAS-time-to-a-new-date-time-field/m-p/793747#M254449</link>
      <description>&lt;P&gt;With the data you have, you can go directly from the variables you start with to the datetime value, using PUT and INPUT:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;sas_datetime=input(put(sas_date,yymmddn8.)||'T'||put(num_time,z6.),B8601DT.);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;There are many datetime informats, you can almost always find one that fits your needs.&lt;/P&gt;</description>
      <pubDate>Tue, 01 Feb 2022 12:57:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/combine-SAS-date-SAS-time-to-a-new-date-time-field/m-p/793747#M254449</guid>
      <dc:creator>s_lassen</dc:creator>
      <dc:date>2022-02-01T12:57:23Z</dc:date>
    </item>
  </channel>
</rss>

