<?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: Combining Date and Time into one variable in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/Combining-Date-and-Time-into-one-variable/m-p/458852#M14217</link>
    <description>&lt;P&gt;This is an awesome reference! Thank you for sharing &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 30 Apr 2018 21:43:57 GMT</pubDate>
    <dc:creator>leila4</dc:creator>
    <dc:date>2018-04-30T21:43:57Z</dc:date>
    <item>
      <title>Combining Date and Time into one variable</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Combining-Date-and-Time-into-one-variable/m-p/458845#M14211</link>
      <description>&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm a relatively new SAS user and finding the formatting of dates and times confusing.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to&amp;nbsp;combine&amp;nbsp;DATE and&amp;nbsp;TIME into one&amp;nbsp;DATE_TIME&amp;nbsp;variable. My dates are numeric, and I've formatted them as yymmdd10. I've looked into concatenating, dhms, and a few other random tidbits I've found and just can't seem to get close to what I need. In an attempt to try something else, I also separated out each component into month, day, year, minute, hour, and second variables - in case that helps with another solution.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need the new variable format to look like yyyy-mm-dd hh:mm.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can anyone help me with this? I'm happy to provide more information as needed! I'm using SAS 9.4.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Mon, 30 Apr 2018 20:58:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Combining-Date-and-Time-into-one-variable/m-p/458845#M14211</guid>
      <dc:creator>leila4</dc:creator>
      <dc:date>2018-04-30T20:58:52Z</dc:date>
    </item>
    <item>
      <title>Re: Combining Date and Time into one variable</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Combining-Date-and-Time-into-one-variable/m-p/458846#M14212</link>
      <description>&lt;P&gt;Assuming you already have them as SAS date and times you can use a function, DHMS.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SAS stores dates as the number of days from January 1, 1960, and times as the number of seconds, so they are typically numbers. But that doesn't work for humans so to present it to look like a date, you use a SAS format to control the appearance. You can do this via a FORMAT statement. See the example below.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data demo;
date = today();
time = time();

date_time = dhms(date, 0, 0, time);

format date_time datetime20. date date9. time time.;
run;

proc print data=demo;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/207535"&gt;@leila4&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Hi everyone,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm a relatively new SAS user and finding the formatting of dates and times confusing.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am trying to&amp;nbsp;combine&amp;nbsp;DATE and&amp;nbsp;TIME into one&amp;nbsp;DATE_TIME&amp;nbsp;variable. My dates are numeric, and I've formatted them as yymmdd10. I've looked into concatenating, dhms, and a few other random tidbits I've found and just can't seem to get close to what I need. In an attempt to try something else, I also separated out each component into month, day, year, minute, hour, and second variables - in case that helps with another solution.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I need the new variable format to look like yyyy-mm-dd hh:mm.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can anyone help me with this? I'm happy to provide more information as needed! I'm using SAS 9.4.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks!&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;BR /&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 30 Apr 2018 21:06:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Combining-Date-and-Time-into-one-variable/m-p/458846#M14212</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-04-30T21:06:47Z</dc:date>
    </item>
    <item>
      <title>Re: Combining Date and Time into one variable</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Combining-Date-and-Time-into-one-variable/m-p/458847#M14213</link>
      <description>There's a tutorial on dates and times here that may be helpful as well: &lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/Working-with-Dates-and-Times-in-SAS-Tutorial/ta-p/424354" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/Working-with-Dates-and-Times-in-SAS-Tutorial/ta-p/424354&lt;/A&gt;</description>
      <pubDate>Mon, 30 Apr 2018 21:08:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Combining-Date-and-Time-into-one-variable/m-p/458847#M14213</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-04-30T21:08:58Z</dc:date>
    </item>
    <item>
      <title>Re: Combining Date and Time into one variable</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Combining-Date-and-Time-into-one-variable/m-p/458848#M14214</link>
      <description>&lt;P&gt;Thanks so much! This works great, except that I need the format to go from:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;18MAR2008:03:00:00&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;to&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2008-03-18 03:00&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a different format that I can make this happen with?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And, thanks for the resource! I'll definitely give it a look.&lt;/P&gt;</description>
      <pubDate>Mon, 30 Apr 2018 21:17:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Combining-Date-and-Time-into-one-variable/m-p/458848#M14214</guid>
      <dc:creator>leila4</dc:creator>
      <dc:date>2018-04-30T21:17:06Z</dc:date>
    </item>
    <item>
      <title>Re: Combining Date and Time into one variable</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Combining-Date-and-Time-into-one-variable/m-p/458849#M14215</link>
      <description>&lt;P&gt;Formats are listed here (I suggest bookmarking it, its a great reference) with them grouped by category&lt;/P&gt;
&lt;P&gt;&lt;A href="http://documentation.sas.com/?docsetId=leforinforref&amp;amp;docsetTarget=n0p2fmevfgj470n17h4k9f27qjag.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en" target="_blank"&gt;http://documentation.sas.com/?docsetId=leforinforref&amp;amp;docsetTarget=n0p2fmevfgj470n17h4k9f27qjag.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I genuinely don't know if that format exists, but you can search the list and see. If it does not, you can roll your own, but I'd avoid that if possible.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 30 Apr 2018 21:19:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Combining-Date-and-Time-into-one-variable/m-p/458849#M14215</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-04-30T21:19:39Z</dc:date>
    </item>
    <item>
      <title>Re: Combining Date and Time into one variable</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Combining-Date-and-Time-into-one-variable/m-p/458851#M14216</link>
      <description>&lt;P&gt;One way is a custom format such as:&lt;/P&gt;
&lt;PRE&gt;proc format library=work;
picture mydatetime
low-high ='%Y-%0m-%0d %0H:%0M'    (datatype=datetime)
;
run;

data _null_;
  x = '18MAR2008:03:00:00'dt;
  put x= mydatetime.;
run;&lt;/PRE&gt;
&lt;P&gt;Since your example did not include any seconds this does not display any. the zeroes in 0m 0d 0H and 0M are so months, days, hours and minutes are displayed with a leading 0 when less than 10.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do not use double quotes in the picture definition here as that will involve the macro processor and not work as expected.&lt;/P&gt;</description>
      <pubDate>Mon, 30 Apr 2018 21:34:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Combining-Date-and-Time-into-one-variable/m-p/458851#M14216</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-04-30T21:34:29Z</dc:date>
    </item>
    <item>
      <title>Re: Combining Date and Time into one variable</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Combining-Date-and-Time-into-one-variable/m-p/458852#M14217</link>
      <description>&lt;P&gt;This is an awesome reference! Thank you for sharing &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 30 Apr 2018 21:43:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Combining-Date-and-Time-into-one-variable/m-p/458852#M14217</guid>
      <dc:creator>leila4</dc:creator>
      <dc:date>2018-04-30T21:43:57Z</dc:date>
    </item>
    <item>
      <title>Re: Combining Date and Time into one variable</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Combining-Date-and-Time-into-one-variable/m-p/458853#M14218</link>
      <description>&lt;P&gt;This worked perfectly! Thank you so much!!&lt;/P&gt;</description>
      <pubDate>Mon, 30 Apr 2018 21:44:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Combining-Date-and-Time-into-one-variable/m-p/458853#M14218</guid>
      <dc:creator>leila4</dc:creator>
      <dc:date>2018-04-30T21:44:15Z</dc:date>
    </item>
  </channel>
</rss>

