<?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: which informat to use when converting  characer date time to numeric date time in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/which-informat-to-use-when-converting-characer-date-time-to/m-p/526871#M143576</link>
    <description>&lt;P&gt;You need to be selective with respect to the length of dtm:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input dtm $19.;
datalines;
2016-06-02T14:44
2016-04-08
;
run;

data want;
set have;
if length(dtm) = 10
then mydtm = dhms(input(dtm,e8601da10.),0,0,0);
else mydtm = input(dtm,e8601dt19.);
format mydtm e8601dt19.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Note that the informat E8601DA10. is equivalent to YYMMDD10.&lt;/P&gt;</description>
    <pubDate>Mon, 14 Jan 2019 08:07:56 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2019-01-14T08:07:56Z</dc:date>
    <item>
      <title>which informat to use when converting  characer date time to numeric date time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/which-informat-to-use-when-converting-characer-date-time-to/m-p/526852#M143569</link>
      <description>&lt;P&gt;Dear,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In my data, the date time variable has the below values. I am using &lt;FONT color="#FF0000"&gt;anydtdtm.&amp;nbsp;&lt;FONT color="#000000"&gt; informat to convert char to numeric, but it is working only for 2nd obs. Which informat should i use to output both rows. Thank you.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;BR /&gt;data have;
input dtm $19.;
datalines;
2016-06-02T14:44
2016-04-08
;

data want;
set have;
ndtm=input(dtm,anydtdtm.);
format ndtm datetime18.;
run;&lt;/PRE&gt;</description>
      <pubDate>Mon, 14 Jan 2019 06:18:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/which-informat-to-use-when-converting-characer-date-time-to/m-p/526852#M143569</guid>
      <dc:creator>knveraraju91</dc:creator>
      <dc:date>2019-01-14T06:18:19Z</dc:date>
    </item>
    <item>
      <title>Re: which informat to use when converting  characer date time to numeric date time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/which-informat-to-use-when-converting-characer-date-time-to/m-p/526861#M143574</link>
      <description>&lt;P&gt;Hello Kn,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm not sure which informat needed in this case . But here is an solutions , which may help to fulfill your request .&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have;
st=compress(substr(scan(dtm,3,'-'),3,1));
if st eq 'T'  then dtm_ = substr(dtm,1,10);
else  dtm_ =dtm;
ndtm=input(dtm_,anydtdte12.);
format ndtm date9.;
drop dtm_ st;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Thanks...&lt;/P&gt;</description>
      <pubDate>Mon, 14 Jan 2019 07:35:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/which-informat-to-use-when-converting-characer-date-time-to/m-p/526861#M143574</guid>
      <dc:creator>singhsahab</dc:creator>
      <dc:date>2019-01-14T07:35:55Z</dc:date>
    </item>
    <item>
      <title>Re: which informat to use when converting  characer date time to numeric date time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/which-informat-to-use-when-converting-characer-date-time-to/m-p/526871#M143576</link>
      <description>&lt;P&gt;You need to be selective with respect to the length of dtm:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input dtm $19.;
datalines;
2016-06-02T14:44
2016-04-08
;
run;

data want;
set have;
if length(dtm) = 10
then mydtm = dhms(input(dtm,e8601da10.),0,0,0);
else mydtm = input(dtm,e8601dt19.);
format mydtm e8601dt19.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Note that the informat E8601DA10. is equivalent to YYMMDD10.&lt;/P&gt;</description>
      <pubDate>Mon, 14 Jan 2019 08:07:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/which-informat-to-use-when-converting-characer-date-time-to/m-p/526871#M143576</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-01-14T08:07:56Z</dc:date>
    </item>
  </channel>
</rss>

