<?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 read in dates from text file with no leading zeroes on month or day? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-in-dates-from-text-file-with-no-leading-zeroes-on/m-p/541642#M149574</link>
    <description>&lt;P&gt;Hello! I'm trying to read in a date variable from a text file. The dates are formatted like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1/1/2000&lt;/P&gt;&lt;P&gt;1/15/2000&lt;/P&gt;&lt;P&gt;12/1/2000&lt;/P&gt;&lt;P&gt;12/12/2000&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There are no leading zeroes on the month or day pieces of the date. I've tried using the&amp;nbsp;ANYDTDTE informat, but it is only recognizing the dates with two digit days, and any date with a one digit day is showing up as missing. I've also tried a few other date informats, but I think since the lengths of the dates in the text file are not consistent, they are not working either. Here is my code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Data Sample;&lt;BR /&gt;Infile 'File_1.txt' dlm='|' firstobs=2 truncover;&lt;BR /&gt;input ID $ date ANYDTDTE.;&lt;BR /&gt;format date mmddyy10.&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any suggestions?&lt;/P&gt;</description>
    <pubDate>Fri, 08 Mar 2019 22:55:27 GMT</pubDate>
    <dc:creator>crockerm12</dc:creator>
    <dc:date>2019-03-08T22:55:27Z</dc:date>
    <item>
      <title>How to read in dates from text file with no leading zeroes on month or day?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-in-dates-from-text-file-with-no-leading-zeroes-on/m-p/541642#M149574</link>
      <description>&lt;P&gt;Hello! I'm trying to read in a date variable from a text file. The dates are formatted like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1/1/2000&lt;/P&gt;&lt;P&gt;1/15/2000&lt;/P&gt;&lt;P&gt;12/1/2000&lt;/P&gt;&lt;P&gt;12/12/2000&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There are no leading zeroes on the month or day pieces of the date. I've tried using the&amp;nbsp;ANYDTDTE informat, but it is only recognizing the dates with two digit days, and any date with a one digit day is showing up as missing. I've also tried a few other date informats, but I think since the lengths of the dates in the text file are not consistent, they are not working either. Here is my code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Data Sample;&lt;BR /&gt;Infile 'File_1.txt' dlm='|' firstobs=2 truncover;&lt;BR /&gt;input ID $ date ANYDTDTE.;&lt;BR /&gt;format date mmddyy10.&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any suggestions?&lt;/P&gt;</description>
      <pubDate>Fri, 08 Mar 2019 22:55:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-in-dates-from-text-file-with-no-leading-zeroes-on/m-p/541642#M149574</guid>
      <dc:creator>crockerm12</dc:creator>
      <dc:date>2019-03-08T22:55:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to read in dates from text file with no leading zeroes on month or day?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-in-dates-from-text-file-with-no-leading-zeroes-on/m-p/541645#M149575</link>
      <description>&lt;P&gt;I do not trust SAS when we ask it to&lt;STRONG&gt; &lt;FONT color="#FF0000"&gt;guess&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input dates anydtdte21.;
format dates mmddyy10.;
cards;
1/1/2000
1/15/2000
12/1/2000
12/12/2000
;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 08 Mar 2019 23:00:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-in-dates-from-text-file-with-no-leading-zeroes-on/m-p/541645#M149575</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-03-08T23:00:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to read in dates from text file with no leading zeroes on month or day?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-in-dates-from-text-file-with-no-leading-zeroes-on/m-p/541647#M149576</link>
      <description>&lt;P&gt;When i add in the 21 to the informat, it throws off the other variables in the text file. It is a text file with several variables separated by a '|', all with varying lengths, if that makes a difference.&lt;/P&gt;</description>
      <pubDate>Fri, 08 Mar 2019 23:05:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-in-dates-from-text-file-with-no-leading-zeroes-on/m-p/541647#M149576</guid>
      <dc:creator>crockerm12</dc:creator>
      <dc:date>2019-03-08T23:05:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to read in dates from text file with no leading zeroes on month or day?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-in-dates-from-text-file-with-no-leading-zeroes-on/m-p/541648#M149577</link>
      <description>&lt;P&gt;Sorry , just read the 10 bytes as max&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have1;
input dates anydtdte10.;
format dates mmddyy10.;
cards;
1/1/2000
1/15/2000
12/1/2000
12/12/2000
;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 08 Mar 2019 23:08:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-in-dates-from-text-file-with-no-leading-zeroes-on/m-p/541648#M149577</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-03-08T23:08:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to read in dates from text file with no leading zeroes on month or day?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-in-dates-from-text-file-with-no-leading-zeroes-on/m-p/541651#M149579</link>
      <description>&lt;P&gt;In your very code, you could use a modified list input using an informat than&amp;nbsp; a formatted input and let : colon format modifier to perform the task of not reading any chars once a delimiter is reached/found.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I.e&amp;nbsp;&lt;STRONG&gt; &amp;nbsp;: ANYDTDTE&amp;nbsp; /*notice the colon*/&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data Sample;
Infile 'File_1.txt' dlm='|' firstobs=2 truncover;
input ID $ date : ANYDTDTE21.;
format date mmddyy10.
run;

 &lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 08 Mar 2019 23:13:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-in-dates-from-text-file-with-no-leading-zeroes-on/m-p/541651#M149579</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-03-08T23:13:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to read in dates from text file with no leading zeroes on month or day?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-in-dates-from-text-file-with-no-leading-zeroes-on/m-p/541652#M149580</link>
      <description>&lt;P&gt;This worked - THANK YOU!!&lt;/P&gt;</description>
      <pubDate>Fri, 08 Mar 2019 23:14:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-in-dates-from-text-file-with-no-leading-zeroes-on/m-p/541652#M149580</guid>
      <dc:creator>crockerm12</dc:creator>
      <dc:date>2019-03-08T23:14:56Z</dc:date>
    </item>
  </channel>
</rss>

