<?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: Convert character datetime to numeric datetime in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Convert-character-datetime-to-numeric-datetime/m-p/690147#M209906</link>
    <description>&lt;P&gt;Thank you for the update&lt;/P&gt;</description>
    <pubDate>Thu, 08 Oct 2020 19:11:05 GMT</pubDate>
    <dc:creator>UcheOkoro</dc:creator>
    <dc:date>2020-10-08T19:11:05Z</dc:date>
    <item>
      <title>Convert character datetime to numeric datetime</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-character-datetime-to-numeric-datetime/m-p/690144#M209904</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please, I have date and time in character form and I need help converting it to SAS datetime format.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="UcheOkoro_0-1602183240390.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/50392i8675431011F2A127/image-size/medium?v=v2&amp;amp;px=400" role="button" title="UcheOkoro_0-1602183240390.png" alt="UcheOkoro_0-1602183240390.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;I am looking for this format&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="UcheOkoro_2-1602183391476.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/50394i10E5D14AD0A41281/image-size/medium?v=v2&amp;amp;px=400" role="button" title="UcheOkoro_2-1602183391476.png" alt="UcheOkoro_2-1602183391476.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Thu, 08 Oct 2020 19:08:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-character-datetime-to-numeric-datetime/m-p/690144#M209904</guid>
      <dc:creator>UcheOkoro</dc:creator>
      <dc:date>2020-10-08T19:08:51Z</dc:date>
    </item>
    <item>
      <title>Re: Convert character datetime to numeric datetime</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-character-datetime-to-numeric-datetime/m-p/690146#M209905</link>
      <description>FYI - I updated your subject line to be more descriptive. Please try and use a more relevant subject line in future posts.</description>
      <pubDate>Thu, 08 Oct 2020 19:09:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-character-datetime-to-numeric-datetime/m-p/690146#M209905</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-10-08T19:09:27Z</dc:date>
    </item>
    <item>
      <title>Re: Convert character datetime to numeric datetime</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-character-datetime-to-numeric-datetime/m-p/690147#M209906</link>
      <description>&lt;P&gt;Thank you for the update&lt;/P&gt;</description>
      <pubDate>Thu, 08 Oct 2020 19:11:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-character-datetime-to-numeric-datetime/m-p/690147#M209906</guid>
      <dc:creator>UcheOkoro</dc:creator>
      <dc:date>2020-10-08T19:11:05Z</dc:date>
    </item>
    <item>
      <title>Re: Convert character datetime to numeric datetime</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-character-datetime-to-numeric-datetime/m-p/690169#M209922</link>
      <description>&lt;P&gt;Please, I used the following codes that was marked as the solution to a similar question asked in the past and marked as the solution but it does not seem to work for me. I guess I may be doing something wrong. I sincerely appreciate your assistance.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data data7f;
Set  data7e;
abx_datetime2=DHMS(Input(Scan(abx_datetime,1,' '),MMDDYY10.),Scan(Scan(abx_datetime,2,' '),1,':'),Scan(Scan(abx_datetime,2,' '),2,':'),Scan(Scan(abx_datetime,2,' '),3,':'));
Format abx_datetime2 DateTime19.;
Run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Thank you in advance&lt;/P&gt;</description>
      <pubDate>Thu, 08 Oct 2020 20:08:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-character-datetime-to-numeric-datetime/m-p/690169#M209922</guid>
      <dc:creator>UcheOkoro</dc:creator>
      <dc:date>2020-10-08T20:08:54Z</dc:date>
    </item>
    <item>
      <title>Re: Convert character datetime to numeric datetime</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-character-datetime-to-numeric-datetime/m-p/690170#M209923</link>
      <description>&lt;P&gt;Convert date and time separately. Use SCAN() to extract the first and second "word", use INPUT() to convert (the date with MMDDYY10., the time with TIME8.), and then the DHMS() function to combine everything into the new variable, to which you assign the DATETIME19. format. Use the time as the "seconds" parameter of DHMS().&lt;/P&gt;</description>
      <pubDate>Thu, 08 Oct 2020 20:10:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-character-datetime-to-numeric-datetime/m-p/690170#M209923</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-10-08T20:10:48Z</dc:date>
    </item>
    <item>
      <title>Re: Convert character datetime to numeric datetime</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-character-datetime-to-numeric-datetime/m-p/690199#M209948</link>
      <description>&lt;P&gt;Thank you for your response.Please,&amp;nbsp; I am not sure I understand clearly how to use the scan statement but I used the following codes for extract data and time but it is not working. I would sincerely appreciate some help writing the code. Thank you in advance.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data _data7f;
Set  _data7e;
abx_date=input(scan(abx_datetime,-1,' '),mmddyy10.);
format abx_date mmddyy10.;
run;

Data _data7f;
Set  _data7f;
abx_time=input(scan(abx_datetime,-1,' '),time8.);
format abx_date time8.;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 08 Oct 2020 20:58:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-character-datetime-to-numeric-datetime/m-p/690199#M209948</guid>
      <dc:creator>UcheOkoro</dc:creator>
      <dc:date>2020-10-08T20:58:48Z</dc:date>
    </item>
    <item>
      <title>Re: Convert character datetime to numeric datetime</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-character-datetime-to-numeric-datetime/m-p/690203#M209952</link>
      <description>&lt;P&gt;You can do that in one step, and it needs small corrections.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data _data7f;
Set  _data7e;
abx_date=input(scan(abx_datetime,1,' '),mmddyy10.); /* 1 instead of -1 */
abx_time=input(scan(abx_datetime,2,' '),time8.); /* 2 instead if -1 */
abx_datetime_num = dhms(abx_date,0,0,abx_time);
format
  abx_date mmddyy10.
  abx_time time8.
  abx_datetime_new e8601dt19.
;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 08 Oct 2020 21:12:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-character-datetime-to-numeric-datetime/m-p/690203#M209952</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-10-08T21:12:06Z</dc:date>
    </item>
    <item>
      <title>Re: Convert character datetime to numeric datetime</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-character-datetime-to-numeric-datetime/m-p/690217#M209963</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/319831"&gt;@UcheOkoro&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the advice that&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;has given you takes care of everything, well and good.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, if things are still not working, would you please run the following code and post the results here?&amp;nbsp; I'm interested in the &lt;EM&gt;results&lt;/EM&gt; not the log.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jim&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Proc Contents Data=_data7e;
RUN;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 08 Oct 2020 22:44:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-character-datetime-to-numeric-datetime/m-p/690217#M209963</guid>
      <dc:creator>jimbarbour</dc:creator>
      <dc:date>2020-10-08T22:44:55Z</dc:date>
    </item>
    <item>
      <title>Re: Convert character datetime to numeric datetime</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-character-datetime-to-numeric-datetime/m-p/690220#M209966</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/319831"&gt;@UcheOkoro&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I just tried some code, see below, and I was able to read the data using an &lt;STRONG&gt;IN&lt;/STRONG&gt;format (anydtdtm16.) and then format the value using Format datetime17.&amp;nbsp; If this is already solved, then do not worry about it, but if not, perhaps it's worth experimenting with the below code.&amp;nbsp; My results are below the code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jim&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA	_data7e;
	FORMAT	Date_Value			DATETIME17.;
	INPUT	Date_Value	&amp;amp;	:	ANYDTDTM16.;
DATALINES;
11/8/2016 22:49
11/14/2016 10:00
11/14/2016 10:04
2/5/2017 16:01
2/5/2017 18:34
;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jimbarbour_0-1602197913836.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/50400i4162799C260DA2EA/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jimbarbour_0-1602197913836.png" alt="jimbarbour_0-1602197913836.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Oct 2020 22:59:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-character-datetime-to-numeric-datetime/m-p/690220#M209966</guid>
      <dc:creator>jimbarbour</dc:creator>
      <dc:date>2020-10-08T22:59:19Z</dc:date>
    </item>
    <item>
      <title>Re: Convert character datetime to numeric datetime</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-character-datetime-to-numeric-datetime/m-p/691970#M210694</link>
      <description>&lt;P&gt;Thank you so much Kurt for the assistance. I am grateful.&lt;/P&gt;
&lt;P&gt;I changed the format for the datetime from e8601dt19. to Datetime19. and it worked just fine.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you again.&lt;/P&gt;</description>
      <pubDate>Thu, 15 Oct 2020 21:43:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-character-datetime-to-numeric-datetime/m-p/691970#M210694</guid>
      <dc:creator>UcheOkoro</dc:creator>
      <dc:date>2020-10-15T21:43:26Z</dc:date>
    </item>
  </channel>
</rss>

