<?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 complete DATE TIME informats list? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/complete-DATE-TIME-informats-list/m-p/456953#M115811</link>
    <description>&lt;P&gt;I know it would be a very long list but.&amp;nbsp; Is there a list of all possible dates, times and datetimes formats with the corresponding SAS INFORMAT to use for each?&amp;nbsp; The SAS documentation for each informat isn't all that helpful.&amp;nbsp; It's mostly trial and error and trial and error and on and on to find on that works if it one exists.&amp;nbsp; Reading in as char and parsing gets rather tedious and is prone to data induced errors.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Right now I'm trying to find the SAS informat to read datetimes like this from a text file:&lt;/P&gt;
&lt;P&gt;07-Apr-2015 11:32 PM&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 24 Apr 2018 16:50:28 GMT</pubDate>
    <dc:creator>rickpaulos</dc:creator>
    <dc:date>2018-04-24T16:50:28Z</dc:date>
    <item>
      <title>complete DATE TIME informats list?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/complete-DATE-TIME-informats-list/m-p/456953#M115811</link>
      <description>&lt;P&gt;I know it would be a very long list but.&amp;nbsp; Is there a list of all possible dates, times and datetimes formats with the corresponding SAS INFORMAT to use for each?&amp;nbsp; The SAS documentation for each informat isn't all that helpful.&amp;nbsp; It's mostly trial and error and trial and error and on and on to find on that works if it one exists.&amp;nbsp; Reading in as char and parsing gets rather tedious and is prone to data induced errors.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Right now I'm trying to find the SAS informat to read datetimes like this from a text file:&lt;/P&gt;
&lt;P&gt;07-Apr-2015 11:32 PM&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 24 Apr 2018 16:50:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/complete-DATE-TIME-informats-list/m-p/456953#M115811</guid>
      <dc:creator>rickpaulos</dc:creator>
      <dc:date>2018-04-24T16:50:28Z</dc:date>
    </item>
    <item>
      <title>Re: complete DATE TIME informats list?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/complete-DATE-TIME-informats-list/m-p/456966#M115821</link>
      <description>&lt;P&gt;Hi:&lt;BR /&gt; Most of the time the "ANY" informats work, ANYDTDTM, for example. Look at the list here: &lt;A href="http://go.documentation.sas.com/?docsetId=allprodslang&amp;amp;docsetTarget=syntaxByType-informat.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en" target="_blank"&gt;http://go.documentation.sas.com/?docsetId=allprodslang&amp;amp;docsetTarget=syntaxByType-informat.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en&lt;/A&gt; the "ANY" informats are at the top of the page and when you click on a format name, there is usually an example that shows which types of dates you can use with the informat.&lt;BR /&gt;&lt;BR /&gt; For me, the ANYDTDTM usually works OK either in an INPUT statement or an INPUT function, as long as my date in the data matches one of their examples.&lt;BR /&gt;&lt;BR /&gt;cynthia&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For example, this worked for me using an INPUT function with ANYDTDTM -- and for TEST2, it also worked in an INPUT statement:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data testinformat;
  length example $1 datestr $21;
  infile datalines dlm=',';
  input example $ datestr $;
  dateinfo = input(datestr,anydtdtm.);
  format dateinfo datetime21.;
return;
datalines;
a,07-Apr-2015 11:32 PM
b,07APR2015
d,07APR2015:23:32:08
d,04072015
e,04/07/15
f,04-15
g,APR2015
h,20150407
i,April 7 2015
;
run;
  
proc print data=testinformat;
run;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;data test2;&lt;BR /&gt;&amp;nbsp; length example $1 ;&lt;BR /&gt;&amp;nbsp; infile datalines dlm=',';&lt;BR /&gt;&amp;nbsp; input example $ dateinfo : anydtdtm.;&lt;BR /&gt;&amp;nbsp; format dateinfo datetime21.;&lt;BR /&gt;return;&lt;BR /&gt;datalines;&lt;BR /&gt;a,07-Apr-2015 11:32 PM&lt;BR /&gt;b,07APR2015&lt;BR /&gt;d,07APR2015:23:32:08&lt;BR /&gt;d,04072015&lt;BR /&gt;e,04/07/15&lt;BR /&gt;f,04-15&lt;BR /&gt;g,APR2015&lt;BR /&gt;h,20150407&lt;BR /&gt;i,April 7 2015&lt;BR /&gt;;&lt;BR /&gt;run;&lt;BR /&gt;&amp;nbsp; &lt;BR /&gt;proc print data=test2;&lt;BR /&gt;run;&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 24 Apr 2018 17:18:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/complete-DATE-TIME-informats-list/m-p/456966#M115821</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2018-04-24T17:18:33Z</dc:date>
    </item>
  </channel>
</rss>

