<?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: Read in file with multiple date formats in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Read-in-file-with-multiple-date-formats/m-p/671845#M201807</link>
    <description>&lt;P&gt;No need for custom formats:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
input date anydtdte10.;
format date yymmddd10.;
datalines;
01JUL2020
2020-07-01
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Although I would rather have (preferred in this order):&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;a consistent date format&lt;/LI&gt;
&lt;LI&gt;a limited, exactly specified list of acceptable date formats, which can be checked&lt;/LI&gt;
&lt;LI&gt;the current garbage that WILL lead to a problem some time in the future&lt;/LI&gt;
&lt;/UL&gt;</description>
    <pubDate>Thu, 23 Jul 2020 14:56:19 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2020-07-23T14:56:19Z</dc:date>
    <item>
      <title>Read in file with multiple date formats</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Read-in-file-with-multiple-date-formats/m-p/671837#M201803</link>
      <description>&lt;P&gt;Hi, I have a text file with a date with multiple date formats.&amp;nbsp; Kind of what's created below in the sample data.&amp;nbsp; I also created a picture format for the date format I need (further below).&amp;nbsp; What I can't figure out is how to conditionally read in the file and maintain the data as a date.&amp;nbsp; The final output needs to have the new date format (newdate.).&amp;nbsp; I'm trying to avoid reading it in as a string then converting it later.&amp;nbsp; Any ideas?&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;*sample data;&lt;/P&gt;&lt;P&gt;data test;&lt;BR /&gt;input date $10.;&lt;BR /&gt;datalines;&lt;BR /&gt;01JUL2020&lt;BR /&gt;2020-07-01&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;*new data format.&lt;/P&gt;&lt;P&gt;proc format;&lt;BR /&gt;picture NewDate other='%Y-%0m-%0d' (datatype=date);&lt;BR /&gt;run;&lt;BR /&gt;%let now=%sysfunc(today(),newdate.);&lt;BR /&gt;%put &amp;amp;now;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Jul 2020 14:46:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Read-in-file-with-multiple-date-formats/m-p/671837#M201803</guid>
      <dc:creator>sas_nut</dc:creator>
      <dc:date>2020-07-23T14:46:49Z</dc:date>
    </item>
    <item>
      <title>Re: Read in file with multiple date formats</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Read-in-file-with-multiple-date-formats/m-p/671845#M201807</link>
      <description>&lt;P&gt;No need for custom formats:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
input date anydtdte10.;
format date yymmddd10.;
datalines;
01JUL2020
2020-07-01
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Although I would rather have (preferred in this order):&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;a consistent date format&lt;/LI&gt;
&lt;LI&gt;a limited, exactly specified list of acceptable date formats, which can be checked&lt;/LI&gt;
&lt;LI&gt;the current garbage that WILL lead to a problem some time in the future&lt;/LI&gt;
&lt;/UL&gt;</description>
      <pubDate>Thu, 23 Jul 2020 14:56:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Read-in-file-with-multiple-date-formats/m-p/671845#M201807</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-07-23T14:56:19Z</dc:date>
    </item>
    <item>
      <title>Re: Read in file with multiple date formats</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Read-in-file-with-multiple-date-formats/m-p/671848#M201808</link>
      <description>Thank you!</description>
      <pubDate>Thu, 23 Jul 2020 14:59:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Read-in-file-with-multiple-date-formats/m-p/671848#M201808</guid>
      <dc:creator>sas_nut</dc:creator>
      <dc:date>2020-07-23T14:59:06Z</dc:date>
    </item>
    <item>
      <title>Re: Read in file with multiple date formats</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Read-in-file-with-multiple-date-formats/m-p/671850#M201810</link>
      <description>&lt;P&gt;If you have two-digit years in the first position they may be treated as dd-mm-yy instead of yy-mm-dd values OR mm-dd-yy, national language rules, and may have missing values using the ANYDTDTE infromat.&lt;/P&gt;
&lt;P&gt;So double check any results with 2 digit years, if any, from your source file, and the range of result for sensibility. If you end up asking "how did that date get in there" these are candidates for odd values in your input and the coding rules for ANYDTDTE&lt;/P&gt;</description>
      <pubDate>Thu, 23 Jul 2020 15:03:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Read-in-file-with-multiple-date-formats/m-p/671850#M201810</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-07-23T15:03:13Z</dc:date>
    </item>
  </channel>
</rss>

