<?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: retain date when first instance of default in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/retain-date-when-first-instance-of-default/m-p/192992#M48436</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Bian,&lt;/P&gt;&lt;P&gt;Forgive me to pick you up . I have lots of time , so take a look at your code . :smileysilly:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data data;&lt;/P&gt;&lt;P&gt;infile cards dsd truncover;&lt;/P&gt;&lt;P&gt;informat record_date mmddyy12.;&lt;/P&gt;&lt;P&gt;format record_date mmddyy10.;&lt;/P&gt;&lt;P&gt;input power_id $ record_date default_reason $;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;test1,2/21/2013,&lt;/P&gt;&lt;P&gt;test1,3/21/2013,&lt;/P&gt;&lt;P&gt;test1,4/21/2013,&lt;/P&gt;&lt;P&gt;test1,5/21/2013,&lt;/P&gt;&lt;P&gt;test1,6/21/2013,&lt;/P&gt;&lt;P&gt;test1,7/21/2013,&lt;/P&gt;&lt;P&gt;test1,8/21/2013,&lt;/P&gt;&lt;P&gt;test1,9/20/2013,PD&lt;/P&gt;&lt;P&gt;test1,10/31/2013,&lt;/P&gt;&lt;P&gt;test1,11/30/2013,&lt;/P&gt;&lt;P&gt;test1,12/31/2013,&lt;/P&gt;&lt;P&gt;test1,1/31/2014,&lt;/P&gt;&lt;P&gt;test1,2/28/2014,&lt;/P&gt;&lt;P&gt;test1,3/31/2014,&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;will get wrong result .&lt;/P&gt;&lt;P&gt;pass_date should be missing.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 23 Jan 2015 06:17:00 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2015-01-23T06:17:00Z</dc:date>
    <item>
      <title>retain date when first instance of default</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/retain-date-when-first-instance-of-default/m-p/192984#M48428</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am trying to identify when a record first goes into default and retain that date as a default date.&amp;nbsp; If the record comes out of default and then goes back into default that would reset the default date.&amp;nbsp; I cannot figure out how to make this happen.&amp;nbsp; Below are have and want datasets with my progress up to this point.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank You,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data data;&lt;/P&gt;&lt;P&gt;infile cards dsd dlm=',';&lt;/P&gt;&lt;P&gt;informat record_date mmddyy10.;&lt;/P&gt;&lt;P&gt;format record_date mmddyy10.;&lt;/P&gt;&lt;P&gt;input power_id $ record_date default_reason $;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;test1,8/31/2013,&lt;/P&gt;&lt;P&gt;test1,9/30/2013,PD&lt;/P&gt;&lt;P&gt;test1,10/31/2013,PD&lt;/P&gt;&lt;P&gt;test1,11/30/2013,PD&lt;/P&gt;&lt;P&gt;test1,12/31/2013,&lt;/P&gt;&lt;P&gt;test1,1/31/2014,&lt;/P&gt;&lt;P&gt;test1,2/28/2014,&lt;/P&gt;&lt;P&gt;test1,3/31/2014,PD&lt;/P&gt;&lt;P&gt;test1,4/30/2014,PD&lt;/P&gt;&lt;P&gt;test1,5/31/2014,&lt;/P&gt;&lt;P&gt;test1,6/30/2014,&lt;/P&gt;&lt;P&gt;test1,7/31/2014,&lt;/P&gt;&lt;P&gt;test1,8/31/2014,&lt;/P&gt;&lt;P&gt;test1,9/30/2014,&lt;/P&gt;&lt;P&gt;test1,10/31/2014,&lt;/P&gt;&lt;P&gt;test1,11/30/2014,&lt;/P&gt;&lt;P&gt;test1,12/31/2014,&lt;/P&gt;&lt;P&gt;test1,1/31/2015,&lt;/P&gt;&lt;P&gt;test2,2/28/2015,PD&lt;/P&gt;&lt;P&gt;test2,3/31/2015,PD&lt;/P&gt;&lt;P&gt;test2,4/30/2015,&lt;/P&gt;&lt;P&gt;test2,5/31/2015,&lt;/P&gt;&lt;P&gt;test2,6/30/2015,&lt;/P&gt;&lt;P&gt;test2,7/31/2015,&lt;/P&gt;&lt;P&gt;test2,8/31/2015,&lt;/P&gt;&lt;P&gt;test2,9/30/2015,&lt;/P&gt;&lt;P&gt;test2,10/31/2015,&lt;/P&gt;&lt;P&gt;test2,11/30/2015,&lt;/P&gt;&lt;P&gt;test2,12/31/2015,PD&lt;/P&gt;&lt;P&gt;test2,1/31/2016,PD&lt;/P&gt;&lt;P&gt;test2,2/29/2016,&lt;/P&gt;&lt;P&gt;test2,3/31/2016,&lt;/P&gt;&lt;P&gt;test2,4/30/2016,&lt;/P&gt;&lt;P&gt;test2,5/31/2016,&lt;/P&gt;&lt;P&gt;test2,6/30/2016,&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data have(keep=power_id record_date default_reason pass_date pass_count first_default_flag);&lt;/P&gt;&lt;P&gt;format pass_date mmddyy10.;&lt;/P&gt;&lt;P&gt;retain pass_date first_default_flag;&lt;/P&gt;&lt;P&gt;set data;&lt;/P&gt;&lt;P&gt;by power_id;&lt;/P&gt;&lt;P&gt;pass_count + 1;&lt;/P&gt;&lt;P&gt;if first.power_id or default_reason ne '' then pass_date = .;&lt;/P&gt;&lt;P&gt;if first.power_id then pass_count = 0;&lt;/P&gt;&lt;P&gt;/*account for records that do not start in default*/&lt;/P&gt;&lt;P&gt;if first.power_id and default_reason = '' then first_default_flag = 0;&lt;/P&gt;&lt;P&gt;else if default_reason ne '' then first_default_flag = 1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if first_default_flag = 1 then do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if first.power_id then pass_date = .;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if first.power_id then pass_count = 0;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if default_reason ne '' then pass_count = 0;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if pass_count = 7 then pass_date = record_date;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if pass_count &amp;gt; 6 and default_reason ne '' then pass_date = .;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;infile cards dsd;&lt;/P&gt;&lt;P&gt;informat record_date pass_date default_date mmddyy10.;&lt;/P&gt;&lt;P&gt;format record_date pass_date default_date mmddyy10.;&lt;/P&gt;&lt;P&gt;input power_id $ record_date default_reason $ pass_date default_date first_default_flag pass_count;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;test1,08/31/2013,,,,0,0&lt;/P&gt;&lt;P&gt;test1,09/30/2013,PD,,09/30/2013,1,0&lt;/P&gt;&lt;P&gt;test1,10/31/2013,PD,,09/30/2013,1,0&lt;/P&gt;&lt;P&gt;test1,11/30/2013,PD,,09/30/2013,1,0&lt;/P&gt;&lt;P&gt;test1,12/31/2013,,,09/30/2013,1,1&lt;/P&gt;&lt;P&gt;test1,01/31/2014,,,09/30/2013,1,2&lt;/P&gt;&lt;P&gt;test1,02/28/2014,,,09/30/2013,1,3&lt;/P&gt;&lt;P&gt;test1,03/31/2014,PD,,09/30/2013,1,0&lt;/P&gt;&lt;P&gt;test1,04/30/2014,PD,,09/30/2013,1,0&lt;/P&gt;&lt;P&gt;test1,05/31/2014,,,09/30/2013,1,1&lt;/P&gt;&lt;P&gt;test1,06/30/2014,,,09/30/2013,1,2&lt;/P&gt;&lt;P&gt;test1,07/31/2014,,,09/30/2013,1,3&lt;/P&gt;&lt;P&gt;test1,08/31/2014,,,09/30/2013,1,4&lt;/P&gt;&lt;P&gt;test1,09/30/2014,,,09/30/2013,1,5&lt;/P&gt;&lt;P&gt;test1,10/31/2014,,,09/30/2013,1,6&lt;/P&gt;&lt;P&gt;test1,11/30/2014,,11/30/2014,09/30/2013,1,7&lt;/P&gt;&lt;P&gt;test1,12/31/2014,,11/30/2014,09/30/2013,1,8&lt;/P&gt;&lt;P&gt;test1,01/31/2015,,11/30/2014,09/30/2013,1,9&lt;/P&gt;&lt;P&gt;test2,02/28/2015,PD,,02/28/2015,1,0&lt;/P&gt;&lt;P&gt;test2,03/31/2015,PD,,02/28/2015,1,0&lt;/P&gt;&lt;P&gt;test2,04/30/2015,,,02/28/2015,1,1&lt;/P&gt;&lt;P&gt;test2,05/31/2015,,,02/28/2015,1,2&lt;/P&gt;&lt;P&gt;test2,06/30/2015,,,02/28/2015,1,3&lt;/P&gt;&lt;P&gt;test2,07/31/2015,,,02/28/2015,1,4&lt;/P&gt;&lt;P&gt;test2,08/31/2015,,,02/28/2015,1,5&lt;/P&gt;&lt;P&gt;test2,09/30/2015,,,02/28/2015,1,6&lt;/P&gt;&lt;P&gt;test2,10/31/2015,,10/31/2015,02/28/2015,1,7&lt;/P&gt;&lt;P&gt;test2,11/30/2015,,10/31/2015,02/28/2015,1,8&lt;/P&gt;&lt;P&gt;test2,12/31/2015,PD,,12/31/2015,1,0&lt;/P&gt;&lt;P&gt;test2,01/31/2016,PD,,12/31/2015,1,0&lt;/P&gt;&lt;P&gt;test2,02/29/2016,,,12/31/2015,1,1&lt;/P&gt;&lt;P&gt;test2,03/31/2016,,,12/31/2015,1,2&lt;/P&gt;&lt;P&gt;test2,04/30/2016,,,12/31/2015,1,3&lt;/P&gt;&lt;P&gt;test2,05/31/2016,,,12/31/2015,1,4&lt;/P&gt;&lt;P&gt;test2,06/30/2016,,,12/31/2015,1,5&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Jan 2015 21:37:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/retain-date-when-first-instance-of-default/m-p/192984#M48428</guid>
      <dc:creator>Steelers_In_DC</dc:creator>
      <dc:date>2015-01-22T21:37:41Z</dc:date>
    </item>
    <item>
      <title>Re: retain date when first instance of default</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/retain-date-when-first-instance-of-default/m-p/192985#M48429</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This is not a trivial exercise, I developed the exact solution you ask for as a solution for a Federal requirement for a project called "Case Mix" when I worked at Washington States DSHS Aging and Disability Services. You can request the code from them, it is public disclosable, but I no longer work for them. Their code is in VBA and MS Access, but it should be easily convertible to SAS.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Our requirement was to track residents in and out of nursing facilities and apply assessments to their periods they were in the facility according to Federal guidelines. There were time lines that had to be applied and defaults if they did not do an assessment in the time given as a grace period by the Federal Government. If the resident left the facility before the "Grace Period" was over, then when they came in they had a new grace period start and any resulting rate, or default, had to be retroactively applied to all open grace periods.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Fun times and took almost a year to work all the bugs out, but it still stands as the "go to way to do it" after more than a decade.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 23 Jan 2015 01:03:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/retain-date-when-first-instance-of-default/m-p/192985#M48429</guid>
      <dc:creator>morgalr</dc:creator>
      <dc:date>2015-01-23T01:03:53Z</dc:date>
    </item>
    <item>
      <title>Re: retain date when first instance of default</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/retain-date-when-first-instance-of-default/m-p/192986#M48430</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Below is a solution.&amp;nbsp; Anyone is welcome to poke holes in it or recommend a more creative way to come up with the same solution.&amp;nbsp; This works but seems remedial to me:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data data;&lt;/P&gt;&lt;P&gt;infile cards dsd;&lt;/P&gt;&lt;P&gt;informat record_date mmddyy10.;&lt;/P&gt;&lt;P&gt;format record_date mmddyy10.;&lt;/P&gt;&lt;P&gt;input power_id $ record_date default_reason $;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;test1,8/31/2013,&lt;/P&gt;&lt;P&gt;test1,9/30/2013,PD&lt;/P&gt;&lt;P&gt;test1,10/31/2013,&lt;/P&gt;&lt;P&gt;test1,11/30/2013,&lt;/P&gt;&lt;P&gt;test1,12/31/2013,&lt;/P&gt;&lt;P&gt;test1,1/31/2014,&lt;/P&gt;&lt;P&gt;test1,2/28/2014,&lt;/P&gt;&lt;P&gt;test1,3/31/2014,&lt;/P&gt;&lt;P&gt;test1,4/30/2014,PD&lt;/P&gt;&lt;P&gt;test1,5/31/2014,&lt;/P&gt;&lt;P&gt;test1,6/30/2014,&lt;/P&gt;&lt;P&gt;test1,7/31/2014,&lt;/P&gt;&lt;P&gt;test1,8/31/2014,&lt;/P&gt;&lt;P&gt;test1,9/30/2014,pd&lt;/P&gt;&lt;P&gt;test1,10/31/2014,pd&lt;/P&gt;&lt;P&gt;test1,11/30/2014,&lt;/P&gt;&lt;P&gt;test1,12/31/2014,&lt;/P&gt;&lt;P&gt;test1,1/31/2015,&lt;/P&gt;&lt;P&gt;test1,2/28/2015,&lt;/P&gt;&lt;P&gt;test1,3/31/2015,&lt;/P&gt;&lt;P&gt;test1,4/30/2015,&lt;/P&gt;&lt;P&gt;test1,5/31/2015,&lt;/P&gt;&lt;P&gt;test1,6/30/2015,&lt;/P&gt;&lt;P&gt;test1,7/31/2015,&lt;/P&gt;&lt;P&gt;test1,8/31/2015,pd&lt;/P&gt;&lt;P&gt;test1,9/30/2015,&lt;/P&gt;&lt;P&gt;test1,10/31/2015,&lt;/P&gt;&lt;P&gt;test1,11/30/2015,&lt;/P&gt;&lt;P&gt;test1,12/31/2015,&lt;/P&gt;&lt;P&gt;test1,1/31/2016,&lt;/P&gt;&lt;P&gt;test1,2/29/2016,&lt;/P&gt;&lt;P&gt;test1,3/31/2016,&lt;/P&gt;&lt;P&gt;test2,8/31/2013,PD&lt;/P&gt;&lt;P&gt;test2,9/30/2013,PD&lt;/P&gt;&lt;P&gt;test2,10/31/2013,&lt;/P&gt;&lt;P&gt;test2,11/30/2013,&lt;/P&gt;&lt;P&gt;test2,12/31/2013,&lt;/P&gt;&lt;P&gt;test2,1/31/2014,&lt;/P&gt;&lt;P&gt;test2,2/28/2014,PD&lt;/P&gt;&lt;P&gt;test2,3/31/2014,&lt;/P&gt;&lt;P&gt;test2,4/30/2014,&lt;/P&gt;&lt;P&gt;test2,5/31/2014,&lt;/P&gt;&lt;P&gt;test2,6/30/2014,&lt;/P&gt;&lt;P&gt;test2,7/31/2014,&lt;/P&gt;&lt;P&gt;test2,8/31/2014,&lt;/P&gt;&lt;P&gt;test2,9/30/2014,&lt;/P&gt;&lt;P&gt;test2,10/31/2014,pd&lt;/P&gt;&lt;P&gt;test2,11/30/2014,&lt;/P&gt;&lt;P&gt;test2,12/31/2014,&lt;/P&gt;&lt;P&gt;test2,1/31/2015,&lt;/P&gt;&lt;P&gt;test2,2/28/2015,pd&lt;/P&gt;&lt;P&gt;test2,3/31/2015,pd&lt;/P&gt;&lt;P&gt;test2,4/30/2015,&lt;/P&gt;&lt;P&gt;test2,5/31/2015,&lt;/P&gt;&lt;P&gt;test2,6/30/2015,&lt;/P&gt;&lt;P&gt;test2,7/31/2015,&lt;/P&gt;&lt;P&gt;test2,8/31/2015,&lt;/P&gt;&lt;P&gt;test2,9/30/2015,&lt;/P&gt;&lt;P&gt;test2,10/31/2015,&lt;/P&gt;&lt;P&gt;test2,11/30/2015,&lt;/P&gt;&lt;P&gt;test2,12/31/2015,&lt;/P&gt;&lt;P&gt;test2,1/31/2016,pd&lt;/P&gt;&lt;P&gt;test2,2/29/2016,&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data have(keep=power_id record_date default_reason pass_date pass_count first_default_flag lpass_count);&lt;/P&gt;&lt;P&gt;format pass_date mmddyy10.;&lt;/P&gt;&lt;P&gt;retain pass_date first_default_flag;&lt;/P&gt;&lt;P&gt;set data;&lt;/P&gt;&lt;P&gt;by power_id;&lt;/P&gt;&lt;P&gt;pass_count + 1;&lt;/P&gt;&lt;P&gt;/*if first.power_id or default_reason ne '' then pass_date = .;*/&lt;/P&gt;&lt;P&gt;if first.power_id then pass_count = 0;&lt;/P&gt;&lt;P&gt;/*account for records that do not start in default*/&lt;/P&gt;&lt;P&gt;if first.power_id and default_reason = '' then first_default_flag = 0;&lt;/P&gt;&lt;P&gt;else if default_reason ne '' then first_default_flag = 1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if first_default_flag = 1 then do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if first.power_id then pass_date = .;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if first.power_id then pass_count = 0;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if default_reason ne '' then pass_count = 0;&lt;/P&gt;&lt;P&gt;/*&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if pass_count = 0 then pass_date = .;*/&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;lpass_count = lag(pass_count);&lt;/P&gt;&lt;P&gt;if lpass_count = 6 then pass_date = record_date;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;format default_date mmddyy10.;&lt;/P&gt;&lt;P&gt;retain default_date;&lt;/P&gt;&lt;P&gt;set have;&lt;/P&gt;&lt;P&gt;by power_id;&lt;/P&gt;&lt;P&gt;pidcount +1;&lt;/P&gt;&lt;P&gt;default_count +1;&lt;/P&gt;&lt;P&gt;if default_reason = '' then default_count = 0;&lt;/P&gt;&lt;P&gt;if first.power_id then pidcount = 1;&lt;/P&gt;&lt;P&gt;if first.power_id and not missing(default_reason) then default_date = record_date;&lt;/P&gt;&lt;P&gt;if not first.power_id then do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if default_count = 1 and lpass_count &amp;gt; 5 then default_date = record_date;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;if default_count = 1 and pass_count = 0 and lpass_count = 0 and not missing(default_reason) then default_date = record_date;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;create table default_date as&lt;/P&gt;&lt;P&gt;select &lt;/P&gt;&lt;P&gt;power_id,&lt;/P&gt;&lt;P&gt;record_date,&lt;/P&gt;&lt;P&gt;default_reason,&lt;/P&gt;&lt;P&gt;default_date,&lt;/P&gt;&lt;P&gt;pass_date&lt;/P&gt;&lt;P&gt;from want&lt;/P&gt;&lt;P&gt;order by&lt;/P&gt;&lt;P&gt;power_id,&lt;/P&gt;&lt;P&gt;record_date;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 23 Jan 2015 01:37:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/retain-date-when-first-instance-of-default/m-p/192986#M48430</guid>
      <dc:creator>Steelers_In_DC</dc:creator>
      <dc:date>2015-01-23T01:37:14Z</dc:date>
    </item>
    <item>
      <title>Re: retain date when first instance of default</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/retain-date-when-first-instance-of-default/m-p/192987#M48431</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The following seems less verbose &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;:&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;STRONG style="color: navy; background: white; font-family: 'Courier New';"&gt;data&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; data;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;infile&lt;/SPAN&gt; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;cards&lt;/SPAN&gt; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;dsd&lt;/SPAN&gt; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;dlm&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: purple; background: white;"&gt;','&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;informat&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; record_date &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: teal; background: white;"&gt;mmddyy10.&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;format&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; record_date &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: teal; background: white;"&gt;mmddyy10.&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;input&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; power_id $ record_date default_reason $;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;cards&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;test1,8/31/2013,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;test1,9/30/2013,PD&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;test1,10/31/2013,PD&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;test1,11/30/2013,PD&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;test1,12/31/2013,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;test1,1/31/2014,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;test1,2/28/2014,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;test1,3/31/2014,PD&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;test1,4/30/2014,PD&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;test1,5/31/2014,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;test1,6/30/2014,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;test1,7/31/2014,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;test1,8/31/2014,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;test1,9/30/2014,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;test1,10/31/2014,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;test1,11/30/2014,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;test1,12/31/2014,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;test1,1/31/2015,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;test2,2/28/2015,PD&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;test2,3/31/2015,PD&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;test2,4/30/2015,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;test2,5/31/2015,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;test2,6/30/2015,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;test2,7/31/2015,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;test2,8/31/2015,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;test2,9/30/2015,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;test2,10/31/2015,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;test2,11/30/2015,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;test2,12/31/2015,PD&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;test2,1/31/2016,PD&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;test2,2/29/2016,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;test2,3/31/2016,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;test2,4/30/2016,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;test2,5/31/2016,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;test2,6/30/2016,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;STRONG style="color: navy; background: white; font-family: 'Courier New';"&gt;run&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;STRONG style="color: navy; background: white; font-family: 'Courier New';"&gt;data&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; want;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;set&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; data;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;by&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; power_id default_reason &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;notsorted&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;retain&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; default_date first_default_flag pass_date;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;format&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; default_date pass_date &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: teal; background: white;"&gt;mmddyy10.&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;if&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; first.power_id &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;then&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;do&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;&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; default_date=&lt;/SPAN&gt;&lt;STRONG style="color: teal; background: white; font-family: 'Courier New';"&gt;.&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;&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; first_default_flag =&lt;/SPAN&gt;&lt;STRONG style="color: teal; background: white; font-family: 'Courier New';"&gt;0&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;end&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;if&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; first.default_reason &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;then&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pass_count=&lt;/SPAN&gt;&lt;STRONG style="color: teal; background: white; font-family: 'Courier New';"&gt;0&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pass_count+&lt;/SPAN&gt;&lt;STRONG style="color: teal; background: white; font-family: 'Courier New';"&gt;1&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;if&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; default_reason=&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: purple; background: white;"&gt;'PD'&lt;/SPAN&gt; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;then&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;do&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;&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; default_date=coalesce(default_date, record_date);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;&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; first_default_flag=&lt;/SPAN&gt;&lt;STRONG style="color: teal; background: white; font-family: 'Courier New';"&gt;1&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;&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; pass_count=&lt;/SPAN&gt;&lt;STRONG style="color: teal; background: white; font-family: 'Courier New';"&gt;0&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;end&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;if&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; first.power_id &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;then&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pass_count=&lt;/SPAN&gt;&lt;STRONG style="color: teal; background: white; font-family: 'Courier New';"&gt;0&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;if&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; pass_count &amp;gt;&lt;/SPAN&gt;&lt;STRONG style="color: teal; background: white; font-family: 'Courier New';"&gt;6&lt;/STRONG&gt; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;then&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pass_date=coalesce(pass_date, record_date);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;else&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; pass_date=&lt;/SPAN&gt;&lt;STRONG style="color: teal; background: white; font-family: 'Courier New';"&gt;.&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; background: white; font-family: 'Courier New';"&gt;run&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 23 Jan 2015 02:33:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/retain-date-when-first-instance-of-default/m-p/192987#M48431</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2015-01-23T02:33:05Z</dc:date>
    </item>
    <item>
      <title>Re: retain date when first instance of default</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/retain-date-when-first-instance-of-default/m-p/192988#M48432</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hai.kuo,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;After 6 months of no default events the pass date is generated.&amp;nbsp; If there is another default event at or after that time the default date is reset and retained from that date unless there is another pass date and default event following.&amp;nbsp; If you look at line 9 and 25 of our results side by side you will see examples of what I am talking about.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 23 Jan 2015 03:06:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/retain-date-when-first-instance-of-default/m-p/192988#M48432</guid>
      <dc:creator>Steelers_In_DC</dc:creator>
      <dc:date>2015-01-23T03:06:14Z</dc:date>
    </item>
    <item>
      <title>Re: retain date when first instance of default</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/retain-date-when-first-instance-of-default/m-p/192989#M48433</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hmmm. My previous attempt was to generate the identical 'want' in your first post, I wasn't pay attention to your down stream development as I assume there should be no change unless you flag it out. So here it is, less verbose.&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;STRONG style="color: navy; background: white; font-family: 'Courier New';"&gt;data&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; data;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;infile&lt;/SPAN&gt; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;cards&lt;/SPAN&gt; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;dsd&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;informat&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; record_date &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: teal; background: white;"&gt;mmddyy10.&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;format&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; record_date &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: teal; background: white;"&gt;mmddyy10.&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;input&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; power_id $ record_date default_reason $;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;cards&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;test1,8/31/2013,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;test1,9/30/2013,PD&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;test1,10/31/2013,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;test1,11/30/2013,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;test1,12/31/2013,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;test1,1/31/2014,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;test1,2/28/2014,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;test1,3/31/2014,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;test1,4/30/2014,PD&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;test1,5/31/2014,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;test1,6/30/2014,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;test1,7/31/2014,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;test1,8/31/2014,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;test1,9/30/2014,pd&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;test1,10/31/2014,pd&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;test1,11/30/2014,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;test1,12/31/2014,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;test1,1/31/2015,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;test1,2/28/2015,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;test1,3/31/2015,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;test1,4/30/2015,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;test1,5/31/2015,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;test1,6/30/2015,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;test1,7/31/2015,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;test1,8/31/2015,pd&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;test1,9/30/2015,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;test1,10/31/2015,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;test1,11/30/2015,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;test1,12/31/2015,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;test1,1/31/2016,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;test1,2/29/2016,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;test1,3/31/2016,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;test2,8/31/2013,PD&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;test2,9/30/2013,PD&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;test2,10/31/2013,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;test2,11/30/2013,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;test2,12/31/2013,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;test2,1/31/2014,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;test2,2/28/2014,PD&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;test2,3/31/2014,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;test2,4/30/2014,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;test2,5/31/2014,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;test2,6/30/2014,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;test2,7/31/2014,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;test2,8/31/2014,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;test2,9/30/2014,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;test2,10/31/2014,pd&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;test2,11/30/2014,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;test2,12/31/2014,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;test2,1/31/2015,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;test2,2/28/2015,pd&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;test2,3/31/2015,pd&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;test2,4/30/2015,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;test2,5/31/2015,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;test2,6/30/2015,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;test2,7/31/2015,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;test2,8/31/2015,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;test2,9/30/2015,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;test2,10/31/2015,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;test2,11/30/2015,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;test2,12/31/2015,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;test2,1/31/2016,pd&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;test2,2/29/2016,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;STRONG style="color: navy; background: white; font-family: 'Courier New';"&gt;run&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;STRONG style="color: navy; background: white; font-family: 'Courier New';"&gt;data&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; want_1;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;set&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; data;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;by&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; power_id default_reason &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;notsorted&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;retain&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; default_date pass_date _six_ct;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;format&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;&amp;nbsp; default_date pass_date &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: teal; background: white;"&gt;mmddyy10.&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;if&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; first.power_id &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;then&lt;/SPAN&gt; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;call&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; missing( default_date, pass_date, _six_ct);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;if&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; first.default_reason &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;then&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; _pass_ct=&lt;/SPAN&gt;&lt;STRONG style="color: teal; background: white; font-family: 'Courier New';"&gt;0&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;if&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; missing(default_reason) &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;then&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; _pass_ct+&lt;/SPAN&gt;&lt;STRONG style="color: teal; background: white; font-family: 'Courier New';"&gt;1&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;if&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; lag(_pass_ct)=&lt;/SPAN&gt;&lt;STRONG style="color: teal; background: white; font-family: 'Courier New';"&gt;6&lt;/STRONG&gt; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;then&lt;/SPAN&gt; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;do&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;;pass_date=record_date;_six_ct=&lt;/SPAN&gt;&lt;STRONG style="color: teal; background: white; font-family: 'Courier New';"&gt;1&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;end&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;if&lt;/SPAN&gt; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;not&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; missing(default_reason) &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;and&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; (_six_ct=&lt;/SPAN&gt;&lt;STRONG style="color: teal; background: white; font-family: 'Courier New';"&gt;1&lt;/STRONG&gt; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;or&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; missing(default_date))&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;then&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; default_date=record_date;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;if&lt;/SPAN&gt; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;not&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; missing(default_reason) &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;then&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; _six_ct=&lt;/SPAN&gt;&lt;STRONG style="color: teal; background: white; font-family: 'Courier New';"&gt;.&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;drop&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; _:;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt; &lt;STRONG style="color: navy; background: white; font-family: 'Courier New';"&gt;run&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 23 Jan 2015 04:16:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/retain-date-when-first-instance-of-default/m-p/192989#M48433</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2015-01-23T04:16:11Z</dc:date>
    </item>
    <item>
      <title>Re: retain date when first instance of default</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/retain-date-when-first-instance-of-default/m-p/192990#M48434</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Very nice solution.&amp;nbsp; Thank you very much.&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 23 Jan 2015 05:05:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/retain-date-when-first-instance-of-default/m-p/192990#M48434</guid>
      <dc:creator>Steelers_In_DC</dc:creator>
      <dc:date>2015-01-23T05:05:19Z</dc:date>
    </item>
    <item>
      <title>Re: retain date when first instance of default</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/retain-date-when-first-instance-of-default/m-p/192991#M48435</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;So if pass_count gt 6 you need to change pass_date default_date ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;data data;
infile cards dsd dlm=',';
informat record_date mmddyy10.;
format record_date mmddyy10.;
input power_id $ record_date default_reason $;
cards;
test1,8/31/2013,
test1,9/30/2013,PD
test1,10/31/2013,PD
test1,11/30/2013,PD
test1,12/31/2013,
test1,1/31/2014,
test1,2/28/2014,
test1,3/31/2014,PD
test1,4/30/2014,PD
test1,5/31/2014,
test1,6/30/2014,
test1,7/31/2014,
test1,8/31/2014,
test1,9/30/2014,
test1,10/31/2014,
test1,11/30/2014,
test1,12/31/2014,
test1,1/31/2015,
test2,2/28/2015,PD
test2,3/31/2015,PD
test2,4/30/2015,
test2,5/31/2015,
test2,6/30/2015,
test2,7/31/2015,
test2,8/31/2015,
test2,9/30/2015,
test2,10/31/2015,
test2,11/30/2015,
test2,12/31/2015,PD
test2,1/31/2016,PD
test2,2/29/2016,
test2,3/31/2016,
test2,4/30/2016,
test2,5/31/2016,
test2,6/30/2016,
;
run;&amp;nbsp;&amp;nbsp; 
data temp; 
 set data;
 by power_id;
 if first.power_id or (default_reason='PD' and lag(default_reason)=' ') then group+1;
run;
data want;
 set temp;
 by power_id group;
 retain pass_date default_date first_default_flag pass_count&amp;nbsp; ;
 if first.group then do;
&amp;nbsp;&amp;nbsp; if default_reason='PD' and (first.power_id or pass_count gt 6 or pass_count=0) then default_date=record_date;
&amp;nbsp;&amp;nbsp; first_default_flag=0; pass_date=.;pass_count=0;
 end;
 if default_reason='PD' then first_default_flag=1;
 if default_reason=' ' and first_default_flag=1 then pass_count+1;
 if pass_count eq 7 then pass_date=record_date;
 format&amp;nbsp;&amp;nbsp; pass_date default_date mmddyy10.;
 drop group;
 run;

&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Xia Keshan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 23 Jan 2015 05:53:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/retain-date-when-first-instance-of-default/m-p/192991#M48435</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2015-01-23T05:53:36Z</dc:date>
    </item>
    <item>
      <title>Re: retain date when first instance of default</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/retain-date-when-first-instance-of-default/m-p/192992#M48436</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Bian,&lt;/P&gt;&lt;P&gt;Forgive me to pick you up . I have lots of time , so take a look at your code . :smileysilly:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data data;&lt;/P&gt;&lt;P&gt;infile cards dsd truncover;&lt;/P&gt;&lt;P&gt;informat record_date mmddyy12.;&lt;/P&gt;&lt;P&gt;format record_date mmddyy10.;&lt;/P&gt;&lt;P&gt;input power_id $ record_date default_reason $;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;test1,2/21/2013,&lt;/P&gt;&lt;P&gt;test1,3/21/2013,&lt;/P&gt;&lt;P&gt;test1,4/21/2013,&lt;/P&gt;&lt;P&gt;test1,5/21/2013,&lt;/P&gt;&lt;P&gt;test1,6/21/2013,&lt;/P&gt;&lt;P&gt;test1,7/21/2013,&lt;/P&gt;&lt;P&gt;test1,8/21/2013,&lt;/P&gt;&lt;P&gt;test1,9/20/2013,PD&lt;/P&gt;&lt;P&gt;test1,10/31/2013,&lt;/P&gt;&lt;P&gt;test1,11/30/2013,&lt;/P&gt;&lt;P&gt;test1,12/31/2013,&lt;/P&gt;&lt;P&gt;test1,1/31/2014,&lt;/P&gt;&lt;P&gt;test1,2/28/2014,&lt;/P&gt;&lt;P&gt;test1,3/31/2014,&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;will get wrong result .&lt;/P&gt;&lt;P&gt;pass_date should be missing.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 23 Jan 2015 06:17:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/retain-date-when-first-instance-of-default/m-p/192992#M48436</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2015-01-23T06:17:00Z</dc:date>
    </item>
  </channel>
</rss>

