<?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: How to convert Character string to SAS Datetime16. in Base SAS in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/How-to-convert-Character-string-to-SAS-Datetime16-in-Base-SAS/m-p/564338#M11031</link>
    <description>&lt;P&gt;Here is a link to SAS date formats&lt;/P&gt;
&lt;P&gt;&lt;FONT style="background-color: #ffffff;"&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/lrcon/65287/HTML/default/viewer.htm#p1wj0wt2ebe2a0n1lv4lem9hdc0v.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/lrcon/65287/HTML/default/viewer.htm#p1wj0wt2ebe2a0n1lv4lem9hdc0v.htm&lt;/A&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 07 Jun 2019 01:35:59 GMT</pubDate>
    <dc:creator>VDD</dc:creator>
    <dc:date>2019-06-07T01:35:59Z</dc:date>
    <item>
      <title>How to convert Character string to SAS Datetime16. in Base SAS</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-convert-Character-string-to-SAS-Datetime16-in-Base-SAS/m-p/564336#M11030</link>
      <description>&lt;P&gt;Hi all!&lt;/P&gt;&lt;P&gt;I am struggling to convert a character string into a time variable.&amp;nbsp; I have a dataset that imports the Time variable like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;11/11/2011 11:20&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;SAS turns this into a Character in the $16. Format.&amp;nbsp; However, I need the Time to display in the DATETIME16. Format.&amp;nbsp;&lt;/P&gt;&lt;P&gt;How do I go about doing this?&amp;nbsp; I have tried an input statement already.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the dataset as I see it in Excel:&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Name&lt;/TD&gt;&lt;TD&gt;Time&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;TD&gt;11/15/2012 09:16&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;B&lt;/TD&gt;&lt;TD&gt;11/15/2012 09:01&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;C&lt;/TD&gt;&lt;TD&gt;11/07/2012 09:51&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;D&lt;/TD&gt;&lt;TD&gt;11/28/2012 12:16&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;E&lt;/TD&gt;&lt;TD&gt;12/13/2012 01:31&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;F&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;12/10/2012 09:36&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 07 Jun 2019 00:32:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-convert-Character-string-to-SAS-Datetime16-in-Base-SAS/m-p/564336#M11030</guid>
      <dc:creator>Singham20</dc:creator>
      <dc:date>2019-06-07T00:32:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert Character string to SAS Datetime16. in Base SAS</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-convert-Character-string-to-SAS-Datetime16-in-Base-SAS/m-p/564338#M11031</link>
      <description>&lt;P&gt;Here is a link to SAS date formats&lt;/P&gt;
&lt;P&gt;&lt;FONT style="background-color: #ffffff;"&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/lrcon/65287/HTML/default/viewer.htm#p1wj0wt2ebe2a0n1lv4lem9hdc0v.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/lrcon/65287/HTML/default/viewer.htm#p1wj0wt2ebe2a0n1lv4lem9hdc0v.htm&lt;/A&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 07 Jun 2019 01:35:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-convert-Character-string-to-SAS-Datetime16-in-Base-SAS/m-p/564338#M11031</guid>
      <dc:creator>VDD</dc:creator>
      <dc:date>2019-06-07T01:35:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert Character string to SAS Datetime16. in Base SAS</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-convert-Character-string-to-SAS-Datetime16-in-Base-SAS/m-p/564339#M11032</link>
      <description>&lt;P&gt;I did look at that before posting the paper.&amp;nbsp; However the formats do not seem to convert the character string to SAS time.&amp;nbsp; It just comes up as a blank.&lt;/P&gt;</description>
      <pubDate>Fri, 07 Jun 2019 01:57:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-convert-Character-string-to-SAS-Datetime16-in-Base-SAS/m-p/564339#M11032</guid>
      <dc:creator>Singham20</dc:creator>
      <dc:date>2019-06-07T01:57:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert Character string to SAS Datetime16. in Base SAS</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-convert-Character-string-to-SAS-Datetime16-in-Base-SAS/m-p/564342#M11035</link>
      <description>&lt;P&gt;So I struggled and finally got the solution:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;Time=input(time2,&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;anydtdtm.&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;)&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;format&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; Time &lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;datetime16.&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 07 Jun 2019 02:21:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-convert-Character-string-to-SAS-Datetime16-in-Base-SAS/m-p/564342#M11035</guid>
      <dc:creator>Singham20</dc:creator>
      <dc:date>2019-06-07T02:21:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert Character string to SAS Datetime16. in Base SAS</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-convert-Character-string-to-SAS-Datetime16-in-Base-SAS/m-p/564345#M11037</link>
      <description>&lt;P&gt;Make sure that the setting for the date is the same in each session. As in, the setting for days and month order. Sometimes it works when running code manually but then you run it on the server and it fails.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So you might want to add&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options datestyle=mdy;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Another way could be to split the string into date vs time and then combine them.&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
	datetime_s = "11/15/2011 11:20";
	date_s = scan(datetime_s,1," ");
	time_s = scan(datetime_s,2," ");
	date_n = input(date_s,mmddyy10.);
	time_n = input(time_s,hhmmss5.);
	datetime_n = dhms(date_n,0,0,time_n);

	format date_n yymmdd10. time_n hhmm5. datetime_n B8601DT.;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 07 Jun 2019 02:41:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-convert-Character-string-to-SAS-Datetime16-in-Base-SAS/m-p/564345#M11037</guid>
      <dc:creator>heffo</dc:creator>
      <dc:date>2019-06-07T02:41:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert Character string to SAS Datetime16. in Base SAS</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-convert-Character-string-to-SAS-Datetime16-in-Base-SAS/m-p/564442#M11054</link>
      <description>&lt;P&gt;Are you sure that you looked at the link.&amp;nbsp; At the bottom is an example that basically is the same as the solution you selected here.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Taken from
http://support.sas.com/documentation/cdl/en/lrcon/65287/HTML/default/viewer.htm#p1wj0wt2ebe2a0n1lv4lem9hdc0v.htm

options nodate pageno=1 linesize=80 pagesize=18;
data test;
   Time1=86399;
   format Time1 datetime.;
   Date1=86399;
   format Date1 date9.;
   Time2=86399;
   format Time2 timeampm.;
run;
proc print data=test;
   title  'Same Number, Different SAS Values';
   footnote1 'Time1 is a SAS DATETIME value';
   footnote2 'Date1 is a SAS DATE value';
   footnote3 'Time2 is a SAS TIME value';
run;
footnote;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 07 Jun 2019 12:16:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-convert-Character-string-to-SAS-Datetime16-in-Base-SAS/m-p/564442#M11054</guid>
      <dc:creator>VDD</dc:creator>
      <dc:date>2019-06-07T12:16:14Z</dc:date>
    </item>
  </channel>
</rss>

