<?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: Character to date conversion - when with missing date components in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Character-to-date-conversion-when-with-missing-date-components/m-p/78094#M22552</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The ISO 8601 INFORMATS can read partial 8601 dates but you have to get ride of that silly 99 and 00.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;DIV style="font-family: Courier New; font-size: 11pt;"&gt;&lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;data&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; aa; &lt;BR /&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;input&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; id date $;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;if&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; length(date) eq &lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;8&lt;/STRONG&gt; &lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;and&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; substr(date,&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;7&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;,&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;2&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;) in(&lt;/SPAN&gt;&lt;SPAN style="color: #800080; background-color: #ffffff;"&gt;'00'&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="color: #800080; background-color: #ffffff;"&gt;'99'&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;) &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;then&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; substr(date,&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;7&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;)=&lt;/SPAN&gt;&lt;SPAN style="color: #800080; background-color: #ffffff;"&gt;'&amp;nbsp; '&lt;/SPAN&gt;; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; iso = input(date,&lt;/SPAN&gt;&lt;SPAN style="color: #008080; background-color: #ffffff;"&gt;B8601DA8.&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;);&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;format&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; iso &lt;/SPAN&gt;&lt;SPAN style="color: #008080; background-color: #ffffff;"&gt;yymmddn.&lt;/SPAN&gt;; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;datalines&lt;/SPAN&gt;; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffc0;"&gt;1&amp;nbsp; 20110304&lt;BR /&gt;8&amp;nbsp; 2011&lt;BR /&gt;2&amp;nbsp; 20090405&lt;BR /&gt;3&amp;nbsp; 20100399&lt;BR /&gt;4&amp;nbsp; 20100300&lt;BR /&gt;5&amp;nbsp; 201004&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;;;;;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;run&lt;/STRONG&gt;; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 26 Sep 2012 18:19:06 GMT</pubDate>
    <dc:creator>data_null__</dc:creator>
    <dc:date>2012-09-26T18:19:06Z</dc:date>
    <item>
      <title>Character to date conversion - when with missing date components</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Character-to-date-conversion-when-with-missing-date-components/m-p/78087#M22545</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I know I can use INPUT to convert a character variable to a date variable. But what if one of the date components is missing or out of range. Here is an example with some of the wrong day component value. Is there an easy way or a function to tell SAS to replace the out of range or missing as say day 1 or day 31 or any day? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data aa; input id date $;&lt;/P&gt;&lt;P&gt;datalines;&lt;/P&gt;&lt;P&gt;1&amp;nbsp; 20110304&lt;/P&gt;&lt;P&gt;2&amp;nbsp; 20090405&lt;/P&gt;&lt;P&gt;3&amp;nbsp; 20100399&lt;/P&gt;&lt;P&gt;4&amp;nbsp; 20100300&lt;/P&gt;&lt;P&gt;5&amp;nbsp; 201004&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;data bb; set aa;&lt;/P&gt;&lt;P&gt;format newdate yymmdd10.;&lt;/P&gt;&lt;P&gt;newdate=input(date, yymmdd10.);&lt;/P&gt;&lt;P&gt;proc print noobs; run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;id&amp;nbsp;&amp;nbsp; date&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; newdate&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (Ideal output)&lt;/P&gt;&lt;P&gt;1 20110304&amp;nbsp; 2011-03-04 &lt;/P&gt;&lt;P&gt;2 20090405&amp;nbsp; 2009-04-05 &lt;/P&gt;&lt;P&gt;3 20100399&amp;nbsp;&amp;nbsp;&amp;nbsp; .&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2010-03-01 (or 2010-03-15, or 2010-03-31)&lt;/P&gt;&lt;P&gt;4 20100300&amp;nbsp;&amp;nbsp;&amp;nbsp; .&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2010-03-01&lt;/P&gt;&lt;P&gt;4 201004&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1920-10-04&amp;nbsp;&amp;nbsp;&amp;nbsp; 2010-04-01&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Sep 2012 16:11:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Character-to-date-conversion-when-with-missing-date-components/m-p/78087#M22545</guid>
      <dc:creator>Solph</dc:creator>
      <dc:date>2012-09-26T16:11:36Z</dc:date>
    </item>
    <item>
      <title>Re: Character to date conversion - when with missing date components</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Character-to-date-conversion-when-with-missing-date-components/m-p/78088#M22546</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi ... if it's always a problem with just the day part (out of range or missing) ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;data bb;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;set aa;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;newdate = input(catt(date,'00'), ?? yymmdd8.);&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;if missing(newdate) then&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; newdate = mdy(input(substr(date,5,2),2.), 1 , input(substr(date,5,2),2.));&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;format newdate yymmdd10.;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;run;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;id&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; date&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; newdate&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt; 1&amp;nbsp;&amp;nbsp;&amp;nbsp; 20110304&amp;nbsp;&amp;nbsp;&amp;nbsp; 2011-03-04&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt; 2&amp;nbsp;&amp;nbsp;&amp;nbsp; 20090405&amp;nbsp;&amp;nbsp;&amp;nbsp; 2009-04-05&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt; 3&amp;nbsp;&amp;nbsp;&amp;nbsp; 20100399&amp;nbsp;&amp;nbsp;&amp;nbsp; 2003-03-01&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt; 4&amp;nbsp;&amp;nbsp;&amp;nbsp; 20100300&amp;nbsp;&amp;nbsp;&amp;nbsp; 2003-03-01&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt; 5&amp;nbsp;&amp;nbsp;&amp;nbsp; 201004&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2004-04-01&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Sep 2012 16:30:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Character-to-date-conversion-when-with-missing-date-components/m-p/78088#M22546</guid>
      <dc:creator>MikeZdeb</dc:creator>
      <dc:date>2012-09-26T16:30:17Z</dc:date>
    </item>
    <item>
      <title>Re: Character to date conversion - when with missing date components</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Character-to-date-conversion-when-with-missing-date-components/m-p/78089#M22547</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Something like :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;newdate=mdy(&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; input(substr(date,5,2),2.), &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; max(1,min(31,input(coalescec(substr(date,7,2),"01"),2.))),&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; input(substr(date,1,4),4.) );&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PG&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Sep 2012 16:46:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Character-to-date-conversion-when-with-missing-date-components/m-p/78089#M22547</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2012-09-26T16:46:27Z</dc:date>
    </item>
    <item>
      <title>Re: Character to date conversion - when with missing date components</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Character-to-date-conversion-when-with-missing-date-components/m-p/78090#M22548</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Mike, nice approach! I guess you meant&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;STRONG&gt;newdate = mdy(input(substr(date,5,2),2.), 1 , input(substr(date,1,4),4.));&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;PG&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Sep 2012 16:59:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Character-to-date-conversion-when-with-missing-date-components/m-p/78090#M22548</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2012-09-26T16:59:32Z</dc:date>
    </item>
    <item>
      <title>Re: Character to date conversion - when with missing date components</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Character-to-date-conversion-when-with-missing-date-components/m-p/78091#M22549</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Mike,&lt;/P&gt;&lt;P&gt;I made changes to your code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data bb;&lt;/P&gt;&lt;P&gt;set aa;&lt;/P&gt;&lt;P&gt;newdate = input(catt(date,'00'), ?? yymmdd8.);&lt;/P&gt;&lt;P&gt;if missing(newdate) then&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; newdate = mdy(input(substr(date,5,2),2.), 1 , &lt;SPAN style="color: #ff0000;"&gt;input(substr(date,1,4),4.));&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;format newdate yymmdd10.;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;proc print;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Sep 2012 16:59:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Character-to-date-conversion-when-with-missing-date-components/m-p/78091#M22549</guid>
      <dc:creator>Linlin</dc:creator>
      <dc:date>2012-09-26T16:59:46Z</dc:date>
    </item>
    <item>
      <title>Re: Character to date conversion - when with missing date components</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Character-to-date-conversion-when-with-missing-date-components/m-p/78092#M22550</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;OK, as long as we are working on each other's code, consider this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;input(substr(date,1,4),4.)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It could be replaced with:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;input(date,4.)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good luck all.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Sep 2012 17:42:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Character-to-date-conversion-when-with-missing-date-components/m-p/78092#M22550</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2012-09-26T17:42:30Z</dc:date>
    </item>
    <item>
      <title>Re: Character to date conversion - when with missing date components</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Character-to-date-conversion-when-with-missing-date-components/m-p/78093#M22551</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi ... thanks, so much for my cutting/pasting my own code&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;also the CATT function part should have had '01' ... the FINAL version (using Astounding's idea about the year portion)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-size: 12.800000190734863px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-family: 'courier new', courier;"&gt;&lt;STRONG style="font-style: inherit; font-family: inherit;"&gt;data bb;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 12.800000190734863px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-family: 'courier new', courier;"&gt;&lt;STRONG style="font-style: inherit; font-family: inherit;"&gt;set aa;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 12.800000190734863px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-family: 'courier new', courier;"&gt;&lt;STRONG style="font-style: inherit; font-family: inherit;"&gt;newdate = input(catt(date,'01'), ?? yymmdd8.);&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 12.800000190734863px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-family: 'courier new', courier;"&gt;&lt;STRONG style="font-style: inherit; font-family: inherit;"&gt;if missing(newdate) then&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 12.800000190734863px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-family: 'courier new', courier;"&gt;&lt;STRONG style="font-style: inherit; font-family: inherit;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; newdate = mdy(input(substr(date,5,2),2.), 1 , input(date,4.));&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 12.800000190734863px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-family: 'courier new', courier;"&gt;&lt;STRONG style="font-style: inherit; font-family: inherit;"&gt;format newdate yymmdd10.;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 12.800000190734863px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-style: inherit; font-family: 'courier new', courier;"&gt;&lt;STRONG style="font-style: inherit; font-family: inherit;"&gt;run;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Sep 2012 18:01:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Character-to-date-conversion-when-with-missing-date-components/m-p/78093#M22551</guid>
      <dc:creator>MikeZdeb</dc:creator>
      <dc:date>2012-09-26T18:01:12Z</dc:date>
    </item>
    <item>
      <title>Re: Character to date conversion - when with missing date components</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Character-to-date-conversion-when-with-missing-date-components/m-p/78094#M22552</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The ISO 8601 INFORMATS can read partial 8601 dates but you have to get ride of that silly 99 and 00.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;DIV style="font-family: Courier New; font-size: 11pt;"&gt;&lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;data&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; aa; &lt;BR /&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;input&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; id date $;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;if&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; length(date) eq &lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;8&lt;/STRONG&gt; &lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;and&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; substr(date,&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;7&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;,&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;2&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;) in(&lt;/SPAN&gt;&lt;SPAN style="color: #800080; background-color: #ffffff;"&gt;'00'&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="color: #800080; background-color: #ffffff;"&gt;'99'&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;) &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;then&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; substr(date,&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;7&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;)=&lt;/SPAN&gt;&lt;SPAN style="color: #800080; background-color: #ffffff;"&gt;'&amp;nbsp; '&lt;/SPAN&gt;; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; iso = input(date,&lt;/SPAN&gt;&lt;SPAN style="color: #008080; background-color: #ffffff;"&gt;B8601DA8.&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;);&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;format&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; iso &lt;/SPAN&gt;&lt;SPAN style="color: #008080; background-color: #ffffff;"&gt;yymmddn.&lt;/SPAN&gt;; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;datalines&lt;/SPAN&gt;; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffc0;"&gt;1&amp;nbsp; 20110304&lt;BR /&gt;8&amp;nbsp; 2011&lt;BR /&gt;2&amp;nbsp; 20090405&lt;BR /&gt;3&amp;nbsp; 20100399&lt;BR /&gt;4&amp;nbsp; 20100300&lt;BR /&gt;5&amp;nbsp; 201004&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;;;;;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;run&lt;/STRONG&gt;; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Sep 2012 18:19:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Character-to-date-conversion-when-with-missing-date-components/m-p/78094#M22552</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2012-09-26T18:19:06Z</dc:date>
    </item>
    <item>
      <title>Re: Character to date conversion - when with missing date components</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Character-to-date-conversion-when-with-missing-date-components/m-p/78095#M22553</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks all. I just tested them all and they all worked.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regarding data_null_'s solution, Does SAS have a similar function like B8601DA8. to handle the month part being blank?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Sep 2012 19:43:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Character-to-date-conversion-when-with-missing-date-components/m-p/78095#M22553</guid>
      <dc:creator>Solph</dc:creator>
      <dc:date>2012-09-26T19:43:28Z</dc:date>
    </item>
    <item>
      <title>Re: Character to date conversion - when with missing date components</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Character-to-date-conversion-when-with-missing-date-components/m-p/78096#M22554</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes see my example.&amp;nbsp; When month is blank the date is set to first day of the year.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Sep 2012 19:57:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Character-to-date-conversion-when-with-missing-date-components/m-p/78096#M22554</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2012-09-26T19:57:05Z</dc:date>
    </item>
    <item>
      <title>Re: Character to date conversion - when with missing date components</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Character-to-date-conversion-when-with-missing-date-components/m-p/78097#M22555</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;With your example, it worked great. But I added another case with "2010&amp;nbsp; 31", it returned with a missing iso value for that record. Any solution?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data aa;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; input id @4 date $char8.;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; if length(date) eq 8 and substr(date,7,2) in('00','99') then substr(date,7)='&amp;nbsp; ';&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; iso = input(date,B8601DA8.);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; format iso yymmddn.;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; datalines;&lt;/P&gt;&lt;P&gt;1&amp;nbsp; 20110304&lt;/P&gt;&lt;P&gt;8&amp;nbsp; 2011&amp;nbsp; &lt;/P&gt;&lt;P&gt;9&amp;nbsp; 2010&amp;nbsp; 31&lt;/P&gt;&lt;P&gt;2&amp;nbsp; 20090405&lt;/P&gt;&lt;P&gt;3&amp;nbsp; 20100399&lt;/P&gt;&lt;P&gt;4&amp;nbsp; 20100300&lt;/P&gt;&lt;P&gt;5&amp;nbsp; 201004&lt;/P&gt;&lt;P&gt;;;;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;proc print; run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Sep 2012 20:10:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Character-to-date-conversion-when-with-missing-date-components/m-p/78097#M22555</guid>
      <dc:creator>Solph</dc:creator>
      <dc:date>2012-09-26T20:10:36Z</dc:date>
    </item>
    <item>
      <title>Re: Character to date conversion - when with missing date components</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Character-to-date-conversion-when-with-missing-date-components/m-p/78098#M22556</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you don't know the month how can the day be useful.&amp;nbsp; The ISO 8601 standard only alows truncation from the right.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Sep 2012 20:30:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Character-to-date-conversion-when-with-missing-date-components/m-p/78098#M22556</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2012-09-26T20:30:19Z</dc:date>
    </item>
    <item>
      <title>Re: Character to date conversion - when with missing date components</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Character-to-date-conversion-when-with-missing-date-components/m-p/78099#M22557</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi ... you can add the TRANWRD function to the data step if you want a blank month as January and a blank day as the 1st of the month ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if you do that, then you can revert to YYMMDD8. if you also correct the 00 and 99&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;data aa;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp; input id @4 date $char8.;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp; &lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;if length(date) eq 8 and substr(date,7,2) in('00','99') then substr(date,7)='&amp;nbsp; ';&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;date = tranwrd(date,'&amp;nbsp; ','01');&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp; newdate = input(date,yymmdd8.);&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp; format iso yymmddn.;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp; datalines;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;1&amp;nbsp; 20110304&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;8&amp;nbsp; 2011&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;9&amp;nbsp; 2010&amp;nbsp; 31&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;2&amp;nbsp; 20090405&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;3&amp;nbsp; 20100399&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;4&amp;nbsp; 20100300&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;5&amp;nbsp; 201004&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Sep 2012 22:55:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Character-to-date-conversion-when-with-missing-date-components/m-p/78099#M22557</guid>
      <dc:creator>MikeZdeb</dc:creator>
      <dc:date>2012-09-26T22:55:47Z</dc:date>
    </item>
    <item>
      <title>Re: Character to date conversion - when with missing date components</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Character-to-date-conversion-when-with-missing-date-components/m-p/78100#M22558</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Many thanks Mike. Indeed the code works both ways (with either day or month, or both, missing). &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;gt; If you don't know the month how can the day be useful.&lt;/P&gt;&lt;P&gt;Data _null, it's just that the date variable wasn't properly processed as a date variable, the integrity of year/month/day isn't always checked, and we'd rather have proxy date values than assign them as missing simply because some date components are missing.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Again thanks everyone for your extremely helpful answers (helped me to see how it can be resolved differently).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Sep 2012 08:42:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Character-to-date-conversion-when-with-missing-date-components/m-p/78100#M22558</guid>
      <dc:creator>Solph</dc:creator>
      <dc:date>2012-09-27T08:42:10Z</dc:date>
    </item>
    <item>
      <title>Re: Character to date conversion - when with missing date components</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Character-to-date-conversion-when-with-missing-date-components/m-p/78101#M22559</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Solph,&lt;/P&gt;&lt;P&gt;I am curious why you always check your questions as "&lt;STRONG&gt;Assumed Answered&lt;/STRONG&gt;"?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Sep 2012 12:35:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Character-to-date-conversion-when-with-missing-date-components/m-p/78101#M22559</guid>
      <dc:creator>Linlin</dc:creator>
      <dc:date>2012-09-27T12:35:23Z</dc:date>
    </item>
  </channel>
</rss>

