<?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 datetime with lenth of $21. to datetime19.? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-character-datetime-with-lenth-of-21-to-datetime19/m-p/512019#M137860</link>
    <description>have a look at paper &lt;A href="http://support.sas.com/resources/papers/proceedings14/1744-2014.pdf" target="_blank"&gt;http://support.sas.com/resources/papers/proceedings14/1744-2014.pdf&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;VFORMAT Lets SAS® Do the Format Searching &lt;BR /&gt;&lt;BR /&gt;Works for INFORMATS too&lt;BR /&gt;</description>
    <pubDate>Sun, 11 Nov 2018 17:48:32 GMT</pubDate>
    <dc:creator>Peter_C</dc:creator>
    <dc:date>2018-11-11T17:48:32Z</dc:date>
    <item>
      <title>How to convert character datetime with lenth of $21. to datetime19.?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-character-datetime-with-lenth-of-21-to-datetime19/m-p/511991#M137840</link>
      <description>&lt;P&gt;hi&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i am tring to conver a charecter field popelated with &lt;STRONG&gt;(2018-09-01 00:00:00)&lt;/STRONG&gt; to datetime19. format .&lt;/P&gt;&lt;P&gt;as i have used the below script but it give me the output of only dates without time:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want (drop=TRANSACTION_DATE  _date );
set b;

format TRANSACTION_DATE_1  YYMMDD10.  ;
informat TRANSACTION_DATE_1  YYMMDD10. ;


_date=substr(TRANSACTION_DATE,1,18);


TRANSACTION_DATE_1=INPUT(_date,YYMMDD10.); 

run;

data want2 (drop=TRANSACTION_DATE_ );
set want;

format TRANSACTION_DATE    YYMMDD10. ;
informat TRANSACTION_DATE  YYMMDD10.;

TRANSACTION_DATE=TRANSACTION_DATE_1; 


run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Thank You&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 11 Nov 2018 11:16:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-character-datetime-with-lenth-of-21-to-datetime19/m-p/511991#M137840</guid>
      <dc:creator>YousefOba</dc:creator>
      <dc:date>2018-11-11T11:16:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert character datetime with lenth of $21. to datetime19.?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-character-datetime-with-lenth-of-21-to-datetime19/m-p/511994#M137841</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/245756"&gt;@YousefOba&lt;/a&gt;&amp;nbsp;and welcome to the SAS Support Communities!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, your dataset b contains a character variable TRANSACTION_DATE of length 21 with datetime values of the form&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;yyyy-mm-dd hh:mm:ss&lt;/PRE&gt;
&lt;P&gt;Actually, length 19 would be sufficient for such values. As a consequence, there will be two additional blanks (most likely) in these strings. Let's make no assumption about the position of these blanks.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example data:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data b;
length transaction_date $21;
input transaction_date $char21.;
cards;
2018-09-01 01:00:00
 2018-09-01 02:00:00
  2018-09-01 03:00:00
 2018-09-01  04:00:00
2018-09-01  05:00:00
2018-09-01   06:00:00
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You can use the ANYDTDTM21. informat to convert these character values into SAS datetime values and then apply the DATETIME19. format to the resulting numbers:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want(drop=transaction_date);
set b;
tadt=input(transaction_date, anydtdtm21.);
format tadt datetime19.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 11 Nov 2018 12:41:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-character-datetime-with-lenth-of-21-to-datetime19/m-p/511994#M137841</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2018-11-11T12:41:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert character datetime with lenth of $21. to datetime19.?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-character-datetime-with-lenth-of-21-to-datetime19/m-p/512019#M137860</link>
      <description>have a look at paper &lt;A href="http://support.sas.com/resources/papers/proceedings14/1744-2014.pdf" target="_blank"&gt;http://support.sas.com/resources/papers/proceedings14/1744-2014.pdf&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;VFORMAT Lets SAS® Do the Format Searching &lt;BR /&gt;&lt;BR /&gt;Works for INFORMATS too&lt;BR /&gt;</description>
      <pubDate>Sun, 11 Nov 2018 17:48:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-character-datetime-with-lenth-of-21-to-datetime19/m-p/512019#M137860</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2018-11-11T17:48:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert character datetime with lenth of $21. to datetime19.?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-character-datetime-with-lenth-of-21-to-datetime19/m-p/512098#M137891</link>
      <description>Thank you very much for support and effort.</description>
      <pubDate>Mon, 12 Nov 2018 07:30:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-character-datetime-with-lenth-of-21-to-datetime19/m-p/512098#M137891</guid>
      <dc:creator>YousefOba</dc:creator>
      <dc:date>2018-11-12T07:30:40Z</dc:date>
    </item>
  </channel>
</rss>

