<?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: how to handle missing date in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/how-to-handle-missing-date/m-p/358492#M84250</link>
    <description>&lt;P&gt;Read First 6 chars only as a char, convert it to a date using input and correct informat and then use INTNX to set it to the end of the month with the alignment option.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Data want;&lt;/P&gt;
&lt;P&gt;input date $6.;&lt;/P&gt;
&lt;P&gt;date_end = intnx('month', input(date, yymm6.), 0, 'e');&lt;/P&gt;
&lt;P&gt;format date_end yymmdd8.;&lt;/P&gt;
&lt;P&gt;cards;&lt;/P&gt;
&lt;P&gt;.....&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 14 May 2017 01:20:53 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2017-05-14T01:20:53Z</dc:date>
    <item>
      <title>how to handle missing date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-handle-missing-date/m-p/358490#M84248</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have the following dataset&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data have;&lt;BR /&gt;input date_of_birth;&lt;BR /&gt;datalines;&lt;BR /&gt;19600101&lt;BR /&gt;190002..&lt;/P&gt;&lt;P&gt;200002..&lt;/P&gt;&lt;P&gt;199812..&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;I want to write a program that will&amp;nbsp;create a new dataset, that replaces ‘..’ by the last day of the respective month. &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Note: I also want to account for leap years. Therefore, for the 2nd value (&lt;/STRONG&gt;190002..), I would want this to read &lt;STRONG&gt;19000229 &lt;/STRONG&gt;because this is a Leap Year&lt;/P&gt;&lt;P&gt;Appreciate all help!&lt;/P&gt;</description>
      <pubDate>Sun, 14 May 2017 00:56:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-handle-missing-date/m-p/358490#M84248</guid>
      <dc:creator>mhinchy</dc:creator>
      <dc:date>2017-05-14T00:56:10Z</dc:date>
    </item>
    <item>
      <title>Re: how to handle missing date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-handle-missing-date/m-p/358492#M84250</link>
      <description>&lt;P&gt;Read First 6 chars only as a char, convert it to a date using input and correct informat and then use INTNX to set it to the end of the month with the alignment option.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Data want;&lt;/P&gt;
&lt;P&gt;input date $6.;&lt;/P&gt;
&lt;P&gt;date_end = intnx('month', input(date, yymm6.), 0, 'e');&lt;/P&gt;
&lt;P&gt;format date_end yymmdd8.;&lt;/P&gt;
&lt;P&gt;cards;&lt;/P&gt;
&lt;P&gt;.....&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 14 May 2017 01:20:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-handle-missing-date/m-p/358492#M84250</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-05-14T01:20:53Z</dc:date>
    </item>
    <item>
      <title>Re: how to handle missing date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-handle-missing-date/m-p/358493#M84251</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
infile datalines missover;
input date_of_birth $10.;
datalines;
19600101
190002
200002
199812
;
run;

data want;
set have;
month=substr(date_of_birth,5,2);
year=substr(date_of_birth,1,4);
day=substr(date_of_birth,7,2);


length date date_imp $50.; 
 
    if day='' then do;  
date=cats(strip(year),strip(put(input(month, best.),z2.)));  
if month="12" then date_imp=compress(put((mdy(1,1,input(year,best.)+1)-1), is8601da.),'-'); 
else date_imp=compress(put((mdy(input(month,best.)+1,1,input(year,best.))-1),is8601da.),'-');    
end;    
else do;       
date=compress(put(mdy(input(month,best.),input(day,best.),input(year,best.)),is8601da.),'-');  
date_imp=compress(date,'-');    
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 14 May 2017 01:23:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-handle-missing-date/m-p/358493#M84251</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2017-05-14T01:23:19Z</dc:date>
    </item>
    <item>
      <title>Re: how to handle missing date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-handle-missing-date/m-p/358494#M84252</link>
      <description>&lt;PRE&gt;data have;
  input cdate_of_birth $;
  format date_of_birth date9.;
  cdate_of_birth=compress(cdate_of_birth,,'kd');
  if length(cdate_of_birth) lt 8 then date_of_birth=
   intnx('month',input(catt(cdate_of_birth,'01'),yymmdd8.),0,'e');
  else date_of_birth=input(cdate_of_birth,yymmdd8.);
  datalines;
19600101
190002..
200002..
199812..
;
&lt;/PRE&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 14 May 2017 01:29:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-handle-missing-date/m-p/358494#M84252</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-05-14T01:29:39Z</dc:date>
    </item>
    <item>
      <title>Re: how to handle missing date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-handle-missing-date/m-p/358495#M84253</link>
      <description>&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt; solution works fine, the only change is we need to use the informat yymmn6.</description>
      <pubDate>Sun, 14 May 2017 01:30:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-handle-missing-date/m-p/358495#M84253</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2017-05-14T01:30:26Z</dc:date>
    </item>
  </channel>
</rss>

