<?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 DATETIME22.3 and char in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Combining-DATETIME22-3-and-char/m-p/154987#M40697</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;How can a datetime variable have only a date part?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It may only show the date but it should have a time part as well.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To create a datetime variable use the dhms() function.&lt;/P&gt;&lt;P&gt;Assuming it's actually a date:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;new_var=dhms(date_var, hour(time_var), minute(time_var), second(time_var));&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If its not a date and is a date time var you can use datepart() function to get the date portion only.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 05 Feb 2015 14:22:27 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2015-02-05T14:22:27Z</dc:date>
    <item>
      <title>Combining DATETIME22.3 and char</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Combining-DATETIME22-3-and-char/m-p/154985#M40695</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear All,&lt;/P&gt;&lt;P&gt;I have a dataset containing a variable DATETIME22.3 with only the date part.&lt;/P&gt;&lt;P&gt;I have a variable $15. with the time part (like 10:00).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How can I combine these two variables in a single Datetime variable?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you for any help...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;BR&lt;/P&gt;&lt;P&gt;Lorenzo!!!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Feb 2015 13:56:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Combining-DATETIME22-3-and-char/m-p/154985#M40695</guid>
      <dc:creator>Lorenzom</dc:creator>
      <dc:date>2015-02-05T13:56:36Z</dc:date>
    </item>
    <item>
      <title>Re: Combining DATETIME22.3 and char</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Combining-DATETIME22-3-and-char/m-p/154986#M40696</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;So you want to merge based on the datepart only?&amp;nbsp; Then you can use&lt;/P&gt;&lt;P&gt;on put(datepart(dt22var),date9.)=substr(textdate,1,9)&lt;/P&gt;&lt;P&gt;Assuming of course both use date9. style format.&lt;/P&gt;&lt;P&gt;So basically just put the datepart into the same format as your text and compare, or convert the text one to number and compare datepart with datepart.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Feb 2015 14:17:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Combining-DATETIME22-3-and-char/m-p/154986#M40696</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2015-02-05T14:17:02Z</dc:date>
    </item>
    <item>
      <title>Re: Combining DATETIME22.3 and char</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Combining-DATETIME22-3-and-char/m-p/154987#M40697</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;How can a datetime variable have only a date part?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It may only show the date but it should have a time part as well.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To create a datetime variable use the dhms() function.&lt;/P&gt;&lt;P&gt;Assuming it's actually a date:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;new_var=dhms(date_var, hour(time_var), minute(time_var), second(time_var));&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If its not a date and is a date time var you can use datepart() function to get the date portion only.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Feb 2015 14:22:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Combining-DATETIME22-3-and-char/m-p/154987#M40697</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2015-02-05T14:22:27Z</dc:date>
    </item>
    <item>
      <title>Re: Combining DATETIME22.3 and char</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Combining-DATETIME22-3-and-char/m-p/154988#M40698</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Convert the time value in the character variable into a real time value (like newval=input(oldval,time8.);)&lt;/P&gt;&lt;P&gt;Then you just add the time value (which is seconds after midnight) to the datetime value (which is seconds after 01jan1960:00:00:00)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Feb 2015 15:04:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Combining-DATETIME22-3-and-char/m-p/154988#M40698</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2015-02-05T15:04:00Z</dc:date>
    </item>
    <item>
      <title>Re: Combining DATETIME22.3 and char</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Combining-DATETIME22-3-and-char/m-p/154989#M40699</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You are right.&lt;/P&gt;&lt;P&gt;In the variable &lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px; background-color: #ffffff;"&gt;DATETIME22.3 &lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px; background-color: #ffffff;"&gt;you have only the date set, the time part is 00:00:00.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want to obtain something like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Var1&lt;/STRONG&gt; &lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px; background-color: #ffffff;"&gt;&lt;EM&gt;DATETIME22.3&lt;/EM&gt;&amp;nbsp; is 22JAN2012:00:00:00.000&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;&lt;STRONG&gt;Var2 &lt;/STRONG&gt;&lt;EM style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;Char(15)&lt;/EM&gt;&lt;SPAN style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&amp;nbsp; is 10:00&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13px; background-color: #ffffff; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&lt;STRONG&gt;Var3 &lt;/STRONG&gt;&lt;/SPAN&gt;&lt;EM style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;DATETIME22.3&lt;/EM&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px; background-color: #ffffff;"&gt; that will be Var1 and var2 combined so &lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px; background-color: #ffffff;"&gt;22JAN2012:&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px; background-color: #ffffff;"&gt;10:00&lt;/SPAN&gt;:00.000&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13px; background-color: #ffffff; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13px; background-color: #ffffff; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;Thank you for any help!!&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Feb 2015 15:06:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Combining-DATETIME22-3-and-char/m-p/154989#M40699</guid>
      <dc:creator>Lorenzom</dc:creator>
      <dc:date>2015-02-05T15:06:55Z</dc:date>
    </item>
    <item>
      <title>Re: Combining DATETIME22.3 and char</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Combining-DATETIME22-3-and-char/m-p/154990#M40700</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If var3 is to be text&lt;/P&gt;&lt;P&gt;var3=put(datepart(var1,date9.)||":"||strip(var2)||"00.000";&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If num&lt;/P&gt;&lt;P&gt;var3=input(put(datepart(var1,date9.)||":"||strip(var2)||"00.000",datetime22.3);&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Feb 2015 15:15:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Combining-DATETIME22-3-and-char/m-p/154990#M40700</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2015-02-05T15:15:01Z</dc:date>
    </item>
    <item>
      <title>Re: Combining DATETIME22.3 and char</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Combining-DATETIME22-3-and-char/m-p/154991#M40701</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;format var3 datetime22.3;&lt;/P&gt;&lt;P&gt;var3 = var1 + input(var2,time5.);&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Feb 2015 15:19:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Combining-DATETIME22-3-and-char/m-p/154991#M40701</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2015-02-05T15:19:50Z</dc:date>
    </item>
    <item>
      <title>Re: Combining DATETIME22.3 and char</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Combining-DATETIME22-3-and-char/m-p/154992#M40702</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;We probably need more information to give you precise answer, but my assumption is:&lt;/P&gt;&lt;P&gt;" variable DATETIME22.3 with only the date part." meaning something like this: "01JAN2015 00:00:00"dt, the time part is always zero., but the variable is numeric.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if this is the case, then you can go either of the following ways:&lt;/P&gt;&lt;P&gt;1. modified solution from &lt;A __default_attr="255172" __jive_macro_name="user" class="jive_macro jive_macro_user" data-objecttype="3" href="https://communities.sas.com/"&gt;&lt;/A&gt;,&lt;/P&gt;&lt;P&gt;new_var=dhms(datepart(date_var), 0, 0, input(time_var, time15.));&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. new_var=input(catx(' ', put(datepart(date_var),date9.),time_var), anydtdtm23.)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Feb 2015 15:24:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Combining-DATETIME22-3-and-char/m-p/154992#M40702</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2015-02-05T15:24:34Z</dc:date>
    </item>
    <item>
      <title>Re: Combining DATETIME22.3 and char</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Combining-DATETIME22-3-and-char/m-p/154993#M40703</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks to all.&lt;/P&gt;&lt;P&gt;The simplest solution is the right one.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you Kurt!&lt;/P&gt;&lt;H6 style="font-weight: normal; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;/H6&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Feb 2015 15:39:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Combining-DATETIME22-3-and-char/m-p/154993#M40703</guid>
      <dc:creator>Lorenzom</dc:creator>
      <dc:date>2015-02-05T15:39:17Z</dc:date>
    </item>
  </channel>
</rss>

