<?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: Date informat with single digit days in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Date-informat-with-single-digit-days/m-p/401599#M97471</link>
    <description>&lt;P&gt;I ended up doing some data manipulation using CAT and SUBSTR functions and found a solution!&lt;/P&gt;&lt;P&gt;Basically I transformed &lt;STRONG&gt;0212000&lt;/STRONG&gt; to&amp;nbsp;&lt;STRONG&gt;02/1/2000&lt;/STRONG&gt; and was able to call an informat&amp;nbsp;which got it to my desired output!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks, I think a light bulb popped into my head while reading the comments.&lt;/P&gt;</description>
    <pubDate>Fri, 06 Oct 2017 04:01:36 GMT</pubDate>
    <dc:creator>Ahzu</dc:creator>
    <dc:date>2017-10-06T04:01:36Z</dc:date>
    <item>
      <title>Date informat with single digit days</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-informat-with-single-digit-days/m-p/401586#M97459</link>
      <description>&lt;P&gt;I am having trouble trying to format dates with single-digit days (no leading zero). The date in the dataset, in particular, corresponds to February 1st, 2000.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;**EDIT** rookie mistake. I forgot to check my log and thought&amp;nbsp;&lt;STRONG&gt;anydtdtew&lt;/STRONG&gt; gave an actual output.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
	format date mmddyy10.;
	informat date anydtdte.;
	INPUT date;
datalines;
0212000
;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Running this code gets me an incorrect date:&lt;/P&gt;&lt;P&gt;06/08/2540&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The following output I want is in the format &lt;STRONG&gt;mmddyy10.&lt;/STRONG&gt;&amp;nbsp;:&lt;/P&gt;&lt;P&gt;02/01/2000&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So I believe the problem lies in the informat&amp;nbsp;&lt;STRONG&gt;anydtdte.&lt;/STRONG&gt;, however, I am not sure which informat&amp;nbsp;to use. I've tried other types of informats&amp;nbsp;(&lt;STRONG&gt;mmddyy7.)&lt;/STRONG&gt; but I can't seem to find the right one.&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;** Solved using CAT and SUBSTR functions to transform the date.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 06 Oct 2017 03:57:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-informat-with-single-digit-days/m-p/401586#M97459</guid>
      <dc:creator>Ahzu</dc:creator>
      <dc:date>2017-10-06T03:57:43Z</dc:date>
    </item>
    <item>
      <title>Re: Date informat with single digit days</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-informat-with-single-digit-days/m-p/401589#M97462</link>
      <description>&lt;P&gt;Can you always guarantee that the month will be 2 digit and the year will be a 4 digit?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;EDIT: Please make sure your code is debugged for other errors when posting. Your INFORMAT is not correct and then SAS defaults to reading the date as a number and then using that number as a date.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 06 Oct 2017 03:14:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-informat-with-single-digit-days/m-p/401589#M97462</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-10-06T03:14:14Z</dc:date>
    </item>
    <item>
      <title>Re: Date informat with single digit days</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-informat-with-single-digit-days/m-p/401590#M97463</link>
      <description>Removing the "w" from anydtdtew could help.</description>
      <pubDate>Fri, 06 Oct 2017 03:12:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-informat-with-single-digit-days/m-p/401590#M97463</guid>
      <dc:creator>error_prone</dc:creator>
      <dc:date>2017-10-06T03:12:36Z</dc:date>
    </item>
    <item>
      <title>Re: Date informat with single digit days</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-informat-with-single-digit-days/m-p/401592#M97465</link>
      <description>&lt;P&gt;I tried your code and it gave me an error.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ERROR: Informat ANYDTDTEW was not found.....&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Removing the "w" in anydtdtew has no error but missing value.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Make it a habit to CHECK the log (LATEST).&lt;/P&gt;</description>
      <pubDate>Fri, 06 Oct 2017 03:23:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-informat-with-single-digit-days/m-p/401592#M97465</guid>
      <dc:creator>ShiroAmada</dc:creator>
      <dc:date>2017-10-06T03:23:00Z</dc:date>
    </item>
    <item>
      <title>Re: Date informat with single digit days</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-informat-with-single-digit-days/m-p/401593#M97466</link>
      <description>&lt;P&gt;Yes, all the months&amp;nbsp;are 2 digits, and the years are all 4 digits.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Running with the informat&amp;nbsp;&lt;STRONG&gt;anydtdte.&lt;/STRONG&gt; gives me a missing value '.'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I forgot to check my log when running my program. Thanks for reminding me, I still have a lot&amp;nbsp;to learn!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 06 Oct 2017 03:34:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-informat-with-single-digit-days/m-p/401593#M97466</guid>
      <dc:creator>Ahzu</dc:creator>
      <dc:date>2017-10-06T03:34:43Z</dc:date>
    </item>
    <item>
      <title>Re: Date informat with single digit days</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-informat-with-single-digit-days/m-p/401595#M97468</link>
      <description>Thanks for reminding me to check my log! I am still a beginner with SAS. But yes, I also get a missing value after removing the 'w'.</description>
      <pubDate>Fri, 06 Oct 2017 03:36:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-informat-with-single-digit-days/m-p/401595#M97468</guid>
      <dc:creator>Ahzu</dc:creator>
      <dc:date>2017-10-06T03:36:43Z</dc:date>
    </item>
    <item>
      <title>Re: Date informat with single digit days</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-informat-with-single-digit-days/m-p/401598#M97470</link>
      <description>&lt;P&gt;I checked here&amp;nbsp;&lt;A href="http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a002605538.htm" target="_self"&gt;http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a002605538.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Yes i think your informat is incorrect.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You might need to come up with data manipulation to address this one.&amp;nbsp; Say read the value as character, check the length, extract using substr day, month and year then use mdy function to put the details back together.&amp;nbsp; I think&amp;nbsp;@Reeza mentioned something about which digit will be affected with no preceeding zero.&lt;/P&gt;</description>
      <pubDate>Fri, 06 Oct 2017 03:57:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-informat-with-single-digit-days/m-p/401598#M97470</guid>
      <dc:creator>ShiroAmada</dc:creator>
      <dc:date>2017-10-06T03:57:32Z</dc:date>
    </item>
    <item>
      <title>Re: Date informat with single digit days</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-informat-with-single-digit-days/m-p/401599#M97471</link>
      <description>&lt;P&gt;I ended up doing some data manipulation using CAT and SUBSTR functions and found a solution!&lt;/P&gt;&lt;P&gt;Basically I transformed &lt;STRONG&gt;0212000&lt;/STRONG&gt; to&amp;nbsp;&lt;STRONG&gt;02/1/2000&lt;/STRONG&gt; and was able to call an informat&amp;nbsp;which got it to my desired output!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks, I think a light bulb popped into my head while reading the comments.&lt;/P&gt;</description>
      <pubDate>Fri, 06 Oct 2017 04:01:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-informat-with-single-digit-days/m-p/401599#M97471</guid>
      <dc:creator>Ahzu</dc:creator>
      <dc:date>2017-10-06T04:01:36Z</dc:date>
    </item>
    <item>
      <title>Re: Date informat with single digit days</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-informat-with-single-digit-days/m-p/401601#M97473</link>
      <description>&lt;P&gt;I am glad you were able to visualize what we all mentioned.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Not checking the log is not limited to "rookie mistake" (but yeah it's frequent among rookies).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Just remember when you check or review the log contents:&lt;/P&gt;&lt;P&gt;1. Clear previous log contents first.&lt;/P&gt;&lt;P&gt;2. Re-submit your code.&lt;/P&gt;&lt;P&gt;3. Check or review the log from top to bottom.&lt;/P&gt;&lt;P&gt;4. Always correct or resolve the first error (and not the latest or bottom error).&amp;nbsp; Remember sas reads sequentially unless you have goto in your script (which i seldom see now).&lt;/P&gt;&lt;P&gt;5. Do steps 1-3 again.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Lastly, an error-free log does not mean your output is correct.&amp;nbsp; A good example is that removing the "w" has no error but with missing value.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 06 Oct 2017 04:06:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-informat-with-single-digit-days/m-p/401601#M97473</guid>
      <dc:creator>ShiroAmada</dc:creator>
      <dc:date>2017-10-06T04:06:59Z</dc:date>
    </item>
    <item>
      <title>Re: Date informat with single digit days</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-informat-with-single-digit-days/m-p/401610#M97477</link>
      <description>&lt;P&gt;The ANYDTDTE. informat cannot handle those 7 digit strings since there is no good way to tell where the missing digit should be added.&lt;/P&gt;
&lt;P&gt;But you should be able to use the new REGEXE features of PROC FORMAT to define your own format.&lt;/P&gt;
&lt;P&gt;Let's call this new informat MDYYYY to emphasize that it assumes there are always 4 digit years and that Month comes before Day.&lt;/P&gt;
&lt;P&gt;I have added a rule to assume that if the string has only 6 digits then assume that it has both a one digit month and a one digit day.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;invalue mdyyyy (default=8)
 's/([01][0-9])([0-9]{5}?)/${1}0$2/' (regexpe) = [mmddyy8.]
 's/(\d)([0-9]{5}?)/0${1}0$2/' (regexpe) = [mmddyy8.]
 '/[0-9]{8}?/' (regexp) = [mmddyy8.]
 other = _error_
;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 06 Oct 2017 05:16:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-informat-with-single-digit-days/m-p/401610#M97477</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-10-06T05:16:42Z</dc:date>
    </item>
  </channel>
</rss>

