<?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 How to convert character datetime to SAS timestamp using proc ds2? in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/How-to-convert-character-datetime-to-SAS-timestamp-using-proc/m-p/298407#M60334</link>
    <description>&lt;P&gt;I would like to convert a character datetime column to SAS timestamp. The dataset is in hadoop and is pretty large.&lt;/P&gt;&lt;P&gt;I tried cast in FedSQL and input statement, they both failed. Can anyone help me with this issue?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Example output:&lt;/P&gt;&lt;P&gt;Character&amp;nbsp; -----------&amp;gt; Timestamp&lt;/P&gt;&lt;P&gt;2001-01-01 00:00:00&amp;nbsp; --------------------&amp;gt;&amp;nbsp; 01Jan2001 00:00:00&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;</description>
    <pubDate>Wed, 14 Sep 2016 19:02:05 GMT</pubDate>
    <dc:creator>SAS42</dc:creator>
    <dc:date>2016-09-14T19:02:05Z</dc:date>
    <item>
      <title>How to convert character datetime to SAS timestamp using proc ds2?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-convert-character-datetime-to-SAS-timestamp-using-proc/m-p/298407#M60334</link>
      <description>&lt;P&gt;I would like to convert a character datetime column to SAS timestamp. The dataset is in hadoop and is pretty large.&lt;/P&gt;&lt;P&gt;I tried cast in FedSQL and input statement, they both failed. Can anyone help me with this issue?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Example output:&lt;/P&gt;&lt;P&gt;Character&amp;nbsp; -----------&amp;gt; Timestamp&lt;/P&gt;&lt;P&gt;2001-01-01 00:00:00&amp;nbsp; --------------------&amp;gt;&amp;nbsp; 01Jan2001 00:00:00&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Wed, 14 Sep 2016 19:02:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-convert-character-datetime-to-SAS-timestamp-using-proc/m-p/298407#M60334</guid>
      <dc:creator>SAS42</dc:creator>
      <dc:date>2016-09-14T19:02:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert character datetime to SAS timestamp using proc ds2?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-convert-character-datetime-to-SAS-timestamp-using-proc/m-p/298422#M60335</link>
      <description>How did it fail and what did you try?&lt;BR /&gt;Pls show the code/log.</description>
      <pubDate>Wed, 14 Sep 2016 19:50:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-convert-character-datetime-to-SAS-timestamp-using-proc/m-p/298422#M60335</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2016-09-14T19:50:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert character datetime to SAS timestamp using proc ds2?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-convert-character-datetime-to-SAS-timestamp-using-proc/m-p/298430#M60336</link>
      <description>&lt;P&gt;FedSQL can work on small dataset but it cannot run inDatabase so it failed for large dataset.&lt;/P&gt;&lt;P&gt;For input: I used (just try to convert time only for an example)&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;ds2&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;data&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;dcl&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;time&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; new_time &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;having&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;format&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;time8.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;method&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;run&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;();&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;set&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; &amp;amp;inputdata.;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;new_tm=input(substr(char_datetime,&lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;,&lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;2&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;) !! &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;':'&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; !! substr(char_datetime,&lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;4&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;,&lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;2&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;) !! &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;':'&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; !! substr(char_&lt;FONT face="Courier New"&gt;datetime&lt;/FONT&gt;,&lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;7&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;,&lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;2&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;),&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;time8.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;);&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;end&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;enddata&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;run&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;quit&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;Here is the log:&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;ERROR: Compilation error.&lt;/P&gt;&lt;P&gt;ERROR: Parse encountered INPUT when expecting one of: identifier constant expression.&lt;/P&gt;&lt;P&gt;ERROR: Line 30: Parse failed: new_tm= &amp;gt;&amp;gt;&amp;gt; input &amp;lt;&amp;lt;&amp;lt; (substr(&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Sep 2016 20:04:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-convert-character-datetime-to-SAS-timestamp-using-proc/m-p/298430#M60336</guid>
      <dc:creator>SAS42</dc:creator>
      <dc:date>2016-09-14T20:04:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert character datetime to SAS timestamp using proc ds2?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-convert-character-datetime-to-SAS-timestamp-using-proc/m-p/298492#M60337</link>
      <description>&lt;PRE&gt;
new_tm=input(substr(char_datetime,1,2) !! ':' !! substr(char_datetime,4,2) !! ':' !! substr(char_datetime,7,2),time8.);

-----&amp;gt;

new_tm=input(char_datetime,anydtdtm32.);


? 

&lt;/PRE&gt;</description>
      <pubDate>Thu, 15 Sep 2016 02:40:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-convert-character-datetime-to-SAS-timestamp-using-proc/m-p/298492#M60337</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-09-15T02:40:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert character datetime to SAS timestamp using proc ds2?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-convert-character-datetime-to-SAS-timestamp-using-proc/m-p/298531#M60338</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/85149"&gt;@SAS42&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;I would like to convert a character datetime column to SAS timestamp. The dataset is in hadoop and is pretty large.&lt;/P&gt;
&lt;P&gt;I tried cast in FedSQL and input statement, they both failed. Can anyone help me with this issue?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example output:&lt;/P&gt;
&lt;P&gt;Character&amp;nbsp; -----------&amp;gt; Timestamp&lt;/P&gt;
&lt;P&gt;2001-01-01 00:00:00&amp;nbsp; --------------------&amp;gt;&amp;nbsp; 01Jan2001 00:00:00&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Only needs a simple input function call with a format SAS introduced with version 9.2:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
x1 = '2001-01-01 00:00:00';
x2 = input(x1,e8601dt19.);
format x2 datetime19.;
put x2=;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Log:&lt;/P&gt;
&lt;PRE&gt;16         data _null_;
17         x1 = '2001-01-01 00:00:00';
18         x2 = input(x1,e8601dt19.);
19         format x2 datetime19.;
20         put x2=;
21         run;

x2=01JAN2001:00:00:00
&lt;/PRE&gt;</description>
      <pubDate>Thu, 15 Sep 2016 06:59:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-convert-character-datetime-to-SAS-timestamp-using-proc/m-p/298531#M60338</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-09-15T06:59:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert character datetime to SAS timestamp using proc ds2?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-convert-character-datetime-to-SAS-timestamp-using-proc/m-p/486113#M71917</link>
      <description>Hi SAS42 ,&lt;BR /&gt;&lt;BR /&gt;Did you find the soultiong for this, am facing the same issue now.can you please help</description>
      <pubDate>Sun, 12 Aug 2018 04:13:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-convert-character-datetime-to-SAS-timestamp-using-proc/m-p/486113#M71917</guid>
      <dc:creator>Saranya_Sub</dc:creator>
      <dc:date>2018-08-12T04:13:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert character datetime to SAS timestamp using proc ds2?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-convert-character-datetime-to-SAS-timestamp-using-proc/m-p/486120#M71918</link>
      <description>&lt;P&gt;Post your question in a new thread. The OP has not been here since 2016, and nobody will see your post but the few who participated in this thread.&lt;/P&gt;</description>
      <pubDate>Sun, 12 Aug 2018 06:50:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-convert-character-datetime-to-SAS-timestamp-using-proc/m-p/486120#M71918</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-08-12T06:50:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert character datetime to SAS timestamp using proc ds2?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-convert-character-datetime-to-SAS-timestamp-using-proc/m-p/486571#M71943</link>
      <description>input(char_column,anydtdtm.) then apply the any date format as per your requirement</description>
      <pubDate>Tue, 14 Aug 2018 07:38:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-convert-character-datetime-to-SAS-timestamp-using-proc/m-p/486571#M71943</guid>
      <dc:creator>Swagat711</dc:creator>
      <dc:date>2018-08-14T07:38:31Z</dc:date>
    </item>
  </channel>
</rss>

