<?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: Meeting a criteria &amp;quot;two in a row&amp;quot; in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Meeting-a-criteria-quot-two-in-a-row-quot/m-p/401679#M278634</link>
    <description>&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;Thank you both for helping me&lt;/STRONG&gt;&lt;/U&gt;! I've tried both of your codes and the only I get to work is the last proposed by &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/76464"&gt;@s_lassen&lt;/a&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And it works! &lt;SPAN&gt;it only select years with &amp;gt;80% with the next year also &amp;gt;80%. &lt;U&gt;&lt;STRONG&gt;BUT!&lt;/STRONG&gt;&lt;/U&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It do not select the FIRST year&amp;nbsp;so in cases were individuals have many years according to the criteria it can look as this below:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;ID&lt;/TD&gt;&lt;TD&gt;Reirement_event&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;12278&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#FF6600"&gt;&lt;STRONG&gt;2005&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;12278&lt;/TD&gt;&lt;TD&gt;2006&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;12294&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;&lt;FONT color="#FF6600"&gt;2002&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;12294&lt;/TD&gt;&lt;TD&gt;2003&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;12294&lt;/TD&gt;&lt;TD&gt;2004&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;12317&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#FF6600"&gt;&lt;STRONG&gt;2002&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;12317&lt;/TD&gt;&lt;TD&gt;2003&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;12317&lt;/TD&gt;&lt;TD&gt;2004&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;12317&lt;/TD&gt;&lt;TD&gt;2005&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;12317&lt;/TD&gt;&lt;TD&gt;2006&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;FONT color="#FF6600"&gt;&lt;STRONG&gt;Can I add some "Select minimum year" for every ID into the program below?&lt;/STRONG&gt;&lt;/FONT&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;This also happens in cases were people 2003 have 81%, then 79% in 2004 and then 82% in 2005 and 2006. Were there becomes a gap (but this is not a problem)&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;ID&lt;/TD&gt;&lt;TD&gt;Reirement_event&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;12322&lt;/TD&gt;&lt;TD&gt;2003&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;12322&lt;/TD&gt;&lt;TD&gt;2005&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;12322&lt;/TD&gt;&lt;TD&gt;2006&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data LIB1.Test2;
set LIB1.Test1;
by ID;
if percent&amp;gt;80 and lag(percent)&amp;gt;80 and not first.ID then do;
retirement_event=Retirement_year-1;
output;
end;
keep ID retirement_event ;
run;&lt;/CODE&gt;&amp;nbsp;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 06 Oct 2017 10:16:16 GMT</pubDate>
    <dc:creator>Weberian</dc:creator>
    <dc:date>2017-10-06T10:16:16Z</dc:date>
    <item>
      <title>Meeting a criteria "two in a row"</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Meeting-a-criteria-quot-two-in-a-row-quot/m-p/400376#M278628</link>
      <description>&lt;P&gt;Here comes a question I cant figure out. To be classified as&amp;nbsp;retired, an individual needs to have &lt;STRONG&gt;atleast 80%&lt;/STRONG&gt; of the annual income from pension -&amp;nbsp;&lt;STRONG&gt;two years in a row&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a longitudinal dataset (short format) with the percentages every year, variables: 2005, 2006, 2007.... 2014. Lets use &lt;EM&gt;Frank&lt;/EM&gt;&amp;nbsp;and &lt;EM&gt;Anna&lt;/EM&gt; as an example:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Frank:&lt;/STRONG&gt; 2005 (82%), 2006 (76%), &lt;U&gt;2007 (81%), 2008 (98%)&lt;/U&gt;, 2009 (100%), 2010 (100%)...&amp;nbsp; which could be witten as [1 0 1 1 1 1]. In other words: Frank&amp;nbsp;should be classified as retired 2007 since both 2007 and 2008 are above 80%.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Anna:&lt;/STRONG&gt; 2005 (0%), 2006 (0%), 2007 (0%), 2008 (0%), 2009 (100%), 2010 (100%) [0 0 0 0 1 1]. Anna should be classified as retired 2009.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;How do I handle this?&lt;/STRONG&gt; The problem is the "two years in a row" thing. Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 02 Oct 2017 18:13:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Meeting-a-criteria-quot-two-in-a-row-quot/m-p/400376#M278628</guid>
      <dc:creator>Weberian</dc:creator>
      <dc:date>2017-10-02T18:13:43Z</dc:date>
    </item>
    <item>
      <title>Re: Meeting a criteria "two in a row"</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Meeting-a-criteria-quot-two-in-a-row-quot/m-p/400411#M278629</link>
      <description>&lt;P&gt;You haven't exactly described your data in a way that makes sense as a SAS data set.&amp;nbsp; I'll illustrate how to go about this, but on some pretty stiff assumptions.&amp;nbsp; If your data doesn't match this, you may need to adjust the program considerably.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;First, assume you have three fields for each observation:&amp;nbsp; name, year, and percent.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Second, assume your percent variable is on a scale of 0 to 100, not 0 to 1.&amp;nbsp; So a value of 50 = 50%.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Third, assume your observations are in sorted order BY NAME YEAR.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Finally, assume you want to add a fourth variable to each observation, with a value of Y or N to indicate retirement year.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;set have;&lt;/P&gt;
&lt;P&gt;by name;&lt;/P&gt;
&lt;P&gt;set have (firstobs=2 keep=percent rename=(percent=next_percent))&lt;/P&gt;
&lt;P&gt;have (keep=percent rename=(percent=next_percent));&lt;/P&gt;
&lt;P&gt;if first.name then ever_retired='N';&lt;/P&gt;
&lt;P&gt;retain ever_retired;&lt;/P&gt;
&lt;P&gt;if ever_retired='N' and percent &amp;gt;= 80 and next_percent &amp;gt;= 80 and last.name=0 then do;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; ever_retired='Y';&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; retired='Y';&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;drop next_percent ever_retired;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It's untested code, but looks about right.&lt;/P&gt;</description>
      <pubDate>Mon, 02 Oct 2017 19:38:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Meeting-a-criteria-quot-two-in-a-row-quot/m-p/400411#M278629</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-10-02T19:38:05Z</dc:date>
    </item>
    <item>
      <title>Re: Meeting a criteria "two in a row"</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Meeting-a-criteria-quot-two-in-a-row-quot/m-p/400437#M278630</link>
      <description>&lt;P&gt;Thank you Astounding. Let me try and I will come back ASAP with more details if it works or not!&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thansk again!&lt;/P&gt;</description>
      <pubDate>Mon, 02 Oct 2017 20:04:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Meeting-a-criteria-quot-two-in-a-row-quot/m-p/400437#M278630</guid>
      <dc:creator>Weberian</dc:creator>
      <dc:date>2017-10-02T20:04:47Z</dc:date>
    </item>
    <item>
      <title>Re: Meeting a criteria "two in a row"</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Meeting-a-criteria-quot-two-in-a-row-quot/m-p/400885#M278631</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/169048"&gt;@Weberian&lt;/a&gt;:&lt;/P&gt;&lt;P&gt;Astounding's solution is "about right", but I think it drops the final observation.&lt;/P&gt;&lt;P&gt;Here is another suggestion;&lt;/P&gt;&lt;PRE&gt;data want;
  set have;
  by name;
  if first.name then
    retired='N';
  retain retired;
  if percent&amp;gt;80 then do;
    if retired='N' and not last.name then do;
      _N_=_N_+1;
      set have (keep=percent rename=(percent=next_percent)) point=_N_;
      if next_percent&amp;gt;80 then
        retired='Y';
      end;
    end;
  else 
    retired='N';
  drop next_percent;
run;&lt;/PRE&gt;&lt;P&gt;This solution is setting the RETIRED variable to 'Y' for all years that are in a series of years with more than 80% of their income coming from pensions. (meaning that&amp;nbsp;if&amp;nbsp;somebody is retired, and then has a year of less than 80% of income coming from pensions, that person&amp;nbsp;switches back to RETIRED='N'). Is&amp;nbsp;that what you want?&lt;/P&gt;&lt;P&gt;Or are you just looking for the first year in such a series for each person, meaning that retirement is a once in a lifetime event? then something like this may work:&lt;/P&gt;&lt;PRE&gt;data want;
  set have;
  by name;
  if percent&amp;gt;80 and lag(percent)&amp;gt;80 and not first.name then do;
    retirement_year=year-1;
    output;
    end;
  keep name retirement_year;
run;&lt;/PRE&gt;&lt;P&gt;Like the previous example, it assumes that the data are sorted by NAME and YEAR, and that the years are consecutive.&lt;/P&gt;</description>
      <pubDate>Wed, 04 Oct 2017 09:45:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Meeting-a-criteria-quot-two-in-a-row-quot/m-p/400885#M278631</guid>
      <dc:creator>s_lassen</dc:creator>
      <dc:date>2017-10-04T09:45:28Z</dc:date>
    </item>
    <item>
      <title>Re: Meeting a criteria "two in a row"</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Meeting-a-criteria-quot-two-in-a-row-quot/m-p/400907#M278632</link>
      <description>&lt;P&gt;&lt;STRONG&gt;Thank you s_lassen for your help. Very&amp;nbsp;appreciated!!!&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Since I am about to do survival analysis, I am interesting in duration (time to retirement) and event (retired y/n).&lt;EM&gt; So it is&amp;nbsp;as&amp;nbsp;you wrote in last sentence - I am only interested in one-life event.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am using several datasets&amp;nbsp;and merge them into one, currently in &lt;STRONG&gt;&lt;U&gt;short-format-style (see attached illustrative&amp;nbsp;Excel)&lt;/U&gt;&lt;/STRONG&gt;. Since my goal is to &lt;U&gt;&lt;STRONG&gt;only have 1 variable&lt;/STRONG&gt;&lt;/U&gt; with retirement year, for example. ID 4 become retired 2004, retirement_year=2004. Then I may drop the other information and only use the exact retirement date as in the Excel-example.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Since I only&amp;nbsp;have one variable for retirement year, it doesnt matter wether I use long or short format?&lt;/LI&gt;&lt;LI&gt;But maybe I have do make it &lt;STRONG&gt;LONG-format&lt;/STRONG&gt; to be able to sort by year (percentage) and use the program you sent me?&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If the Excel doesn't work:&amp;nbsp;&lt;A href="https://imgur.com/a/31naK" target="_blank"&gt;https://imgur.com/a/31naK&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 04 Oct 2017 11:17:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Meeting-a-criteria-quot-two-in-a-row-quot/m-p/400907#M278632</guid>
      <dc:creator>Weberian</dc:creator>
      <dc:date>2017-10-04T11:17:10Z</dc:date>
    </item>
    <item>
      <title>Re: Meeting a criteria "two in a row"</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Meeting-a-criteria-quot-two-in-a-row-quot/m-p/401020#M278633</link>
      <description>&lt;P&gt;While my solution is untested, I think it should be fine.&amp;nbsp; It won't drop the final observation because the second SET statement mentions HAVE twice.&amp;nbsp; So the first SET statement determines when the DATA step ends.&amp;nbsp; At any rate, all of that assumes there is nothing else I overlooked (such as failing to set retired to "N" which would be a possible desired outcome instead of blank vs. "Y").&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/76464"&gt;@s_lassen&lt;/a&gt;&amp;nbsp;you might want to take a look at what happens if you have three observations in a row with percent &amp;gt; 80.&amp;nbsp; I'm not sure your logic is complete for that.&amp;nbsp; Looks like a viable approach, though.&lt;/P&gt;</description>
      <pubDate>Wed, 04 Oct 2017 15:32:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Meeting-a-criteria-quot-two-in-a-row-quot/m-p/401020#M278633</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-10-04T15:32:00Z</dc:date>
    </item>
    <item>
      <title>Re: Meeting a criteria "two in a row"</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Meeting-a-criteria-quot-two-in-a-row-quot/m-p/401679#M278634</link>
      <description>&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;Thank you both for helping me&lt;/STRONG&gt;&lt;/U&gt;! I've tried both of your codes and the only I get to work is the last proposed by &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/76464"&gt;@s_lassen&lt;/a&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And it works! &lt;SPAN&gt;it only select years with &amp;gt;80% with the next year also &amp;gt;80%. &lt;U&gt;&lt;STRONG&gt;BUT!&lt;/STRONG&gt;&lt;/U&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It do not select the FIRST year&amp;nbsp;so in cases were individuals have many years according to the criteria it can look as this below:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;ID&lt;/TD&gt;&lt;TD&gt;Reirement_event&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;12278&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#FF6600"&gt;&lt;STRONG&gt;2005&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;12278&lt;/TD&gt;&lt;TD&gt;2006&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;12294&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;&lt;FONT color="#FF6600"&gt;2002&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;12294&lt;/TD&gt;&lt;TD&gt;2003&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;12294&lt;/TD&gt;&lt;TD&gt;2004&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;12317&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#FF6600"&gt;&lt;STRONG&gt;2002&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;12317&lt;/TD&gt;&lt;TD&gt;2003&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;12317&lt;/TD&gt;&lt;TD&gt;2004&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;12317&lt;/TD&gt;&lt;TD&gt;2005&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;12317&lt;/TD&gt;&lt;TD&gt;2006&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;FONT color="#FF6600"&gt;&lt;STRONG&gt;Can I add some "Select minimum year" for every ID into the program below?&lt;/STRONG&gt;&lt;/FONT&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;This also happens in cases were people 2003 have 81%, then 79% in 2004 and then 82% in 2005 and 2006. Were there becomes a gap (but this is not a problem)&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;ID&lt;/TD&gt;&lt;TD&gt;Reirement_event&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;12322&lt;/TD&gt;&lt;TD&gt;2003&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;12322&lt;/TD&gt;&lt;TD&gt;2005&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;12322&lt;/TD&gt;&lt;TD&gt;2006&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data LIB1.Test2;
set LIB1.Test1;
by ID;
if percent&amp;gt;80 and lag(percent)&amp;gt;80 and not first.ID then do;
retirement_event=Retirement_year-1;
output;
end;
keep ID retirement_event ;
run;&lt;/CODE&gt;&amp;nbsp;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 06 Oct 2017 10:16:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Meeting-a-criteria-quot-two-in-a-row-quot/m-p/401679#M278634</guid>
      <dc:creator>Weberian</dc:creator>
      <dc:date>2017-10-06T10:16:16Z</dc:date>
    </item>
    <item>
      <title>Re: Meeting a criteria "two in a row"</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Meeting-a-criteria-quot-two-in-a-row-quot/m-p/402032#M278635</link>
      <description>&lt;P&gt;Any year that is part of consecutive percent &amp;gt;=80 is retire='Y',&amp;nbsp; otherwise retire='N'.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want (drop=nxt_pct);
  set have (keep=name);
  by name;

  merge have
        have (firstobs=2 keep=percent rename=(percent=nxt_pct));

  retire=  ifc(min(lag(percent),percent)&amp;gt;=80 and first.name=0,'Y','N');
  if min(percent,nxt_pct)&amp;gt;=80 then retire='Y';

run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 07 Oct 2017 03:09:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Meeting-a-criteria-quot-two-in-a-row-quot/m-p/402032#M278635</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2017-10-07T03:09:54Z</dc:date>
    </item>
    <item>
      <title>Re: Meeting a criteria "two in a row"</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Meeting-a-criteria-quot-two-in-a-row-quot/m-p/402422#M278636</link>
      <description>&lt;P&gt;Thank you all for helping me. It works now.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4954"&gt;@Astounding&lt;/a&gt;&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/76464"&gt;@s_lassen&lt;/a&gt;&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31461"&gt;@mkeintz&lt;/a&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 09 Oct 2017 16:35:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Meeting-a-criteria-quot-two-in-a-row-quot/m-p/402422#M278636</guid>
      <dc:creator>Weberian</dc:creator>
      <dc:date>2017-10-09T16:35:02Z</dc:date>
    </item>
  </channel>
</rss>

