<?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: Character to Date in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Character-to-Date/m-p/245715#M309257</link>
    <description>The data is already in SAS.&lt;BR /&gt;datetimevar=input(compress(char_val), anydtdtm.); DOES NOT WORK.&lt;BR /&gt;samnan's code works. Thanks!</description>
    <pubDate>Sun, 24 Jan 2016 18:18:37 GMT</pubDate>
    <dc:creator>ZZB</dc:creator>
    <dc:date>2016-01-24T18:18:37Z</dc:date>
    <item>
      <title>Character to Date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Character-to-Date/m-p/245683#M309253</link>
      <description>&lt;P&gt;How to convert the following Charater to Date format?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For example, raw variable DATE "01 MAR 2013 00:00:02.358". The length is 24. There are space between '01' and 'MAR' and '2013' and '00'.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How to seperate it into two column '03/01/2013' + 'hh:mm:ss:sss' or 'hh:mm:ss'. Both are date format. Thanks!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 24 Jan 2016 07:46:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Character-to-Date/m-p/245683#M309253</guid>
      <dc:creator>ZZB</dc:creator>
      <dc:date>2016-01-24T07:46:29Z</dc:date>
    </item>
    <item>
      <title>Re: Character to Date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Character-to-Date/m-p/245685#M309254</link>
      <description>&lt;P&gt;Are you reading these from a text file or is the data already in SAS?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can try compress and input to read in the data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;untested:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;datetimevar=input(compress(char_val), anydtdtm.);
var_datepart=datepart(datetimevar);
var_timepart=timepart(datetimevar);

format var_datepart date9. var_timepart time8.;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 24 Jan 2016 08:14:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Character-to-Date/m-p/245685#M309254</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-01-24T08:14:55Z</dc:date>
    </item>
    <item>
      <title>Re: Character to Date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Character-to-Date/m-p/245691#M309255</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;34         data _null_;
35            input dt &amp;amp; datetime.;
36            put (dt)(=datetime22.3);
37            list;
38            cards;

dt=01MAR2013:00:00:02.358
RULE:      ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0                     
39         01 MAR 2013 00:00:02.358&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 24 Jan 2016 11:27:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Character-to-Date/m-p/245691#M309255</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2016-01-24T11:27:57Z</dc:date>
    </item>
    <item>
      <title>Re: Character to Date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Character-to-Date/m-p/245707#M309256</link>
      <description>&lt;P&gt;Hi ZZB;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;try this&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data have;&lt;BR /&gt;DATE = "01 MAR 2013 00:00:02.358";&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data want;&lt;BR /&gt;set have;&lt;BR /&gt;NewDate = input(compress (substr(DATE ,1,11)),date9.);&lt;BR /&gt;NewTime = input( scan(DATE,-1,' '),time12.);&lt;BR /&gt;format NewDate date9. NewTime time12.;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Sun, 24 Jan 2016 16:48:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Character-to-Date/m-p/245707#M309256</guid>
      <dc:creator>samnan</dc:creator>
      <dc:date>2016-01-24T16:48:30Z</dc:date>
    </item>
    <item>
      <title>Re: Character to Date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Character-to-Date/m-p/245715#M309257</link>
      <description>The data is already in SAS.&lt;BR /&gt;datetimevar=input(compress(char_val), anydtdtm.); DOES NOT WORK.&lt;BR /&gt;samnan's code works. Thanks!</description>
      <pubDate>Sun, 24 Jan 2016 18:18:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Character-to-Date/m-p/245715#M309257</guid>
      <dc:creator>ZZB</dc:creator>
      <dc:date>2016-01-24T18:18:37Z</dc:date>
    </item>
    <item>
      <title>Re: Character to Date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Character-to-Date/m-p/245801#M309258</link>
      <description>&lt;P&gt;The informat provided by&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15410"&gt;@data_null__﻿&lt;/a&gt;&amp;nbsp;is the correct informat. Correcting the informat fixes the issues.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;

original_var = "01 MAR 2013 00:00:02.358";
temp=compress(original_var);

dt_var=input(original_var, datetime24.3);
date_part=datepart(dt_var);
time_part=timepart(dt_var);

format dt_var datetime24.3 date_part date9. time_part time11.3;
run;

proc print data=have;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 25 Jan 2016 03:26:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Character-to-Date/m-p/245801#M309258</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-01-25T03:26:51Z</dc:date>
    </item>
  </channel>
</rss>

