<?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 Looking for exceptions in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Looking-for-exceptions/m-p/58038#M16210</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; Thank you.&amp;nbsp; This is very helpful as I know next to nothing about SQL.&amp;nbsp; I will try this right now.&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 17 Feb 2012 21:45:05 GMT</pubDate>
    <dc:creator>Noelle125</dc:creator>
    <dc:date>2012-02-17T21:45:05Z</dc:date>
    <item>
      <title>Looking for exceptions</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Looking-for-exceptions/m-p/58034#M16206</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am struggling with what I believe is a fairly simple logic string.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My data looks like this: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="1" cellpadding="3" cellspacing="0" class="jiveBorder" style="width: 100%; border: 1px solid #000000;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TH align="center" style="background-color: #6690bc;" valign="middle"&gt;&lt;SPAN style="color: #ffffff;"&gt;&lt;STRONG&gt;Incident ID&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/TH&gt;&lt;TH align="center" style="background-color: #6690bc;" valign="middle"&gt;&lt;SPAN style="color: #ffffff;"&gt;&lt;STRONG&gt;Year&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/TH&gt;&lt;TH align="center" style="background-color: #6690bc;" valign="middle"&gt;&lt;SPAN style="color: #ffffff;"&gt;&lt;STRONG&gt;Discscore&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/TH&gt;&lt;TH align="center" style="background-color: #6690bc;" valign="middle"&gt;&lt;SPAN style="color: #ffffff;"&gt;&lt;STRONG&gt;Emp No.&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/TH&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;2005&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;123&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;2006&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;TD&gt;123&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;2007&lt;/TD&gt;&lt;TD&gt;0.5&lt;/TD&gt;&lt;TD&gt;123&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;2008&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;123&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;TD&gt;2009&lt;/TD&gt;&lt;TD&gt;1.5&lt;/TD&gt;&lt;TD&gt;123&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;6&lt;/TD&gt;&lt;TD&gt;2001&lt;/TD&gt;&lt;TD&gt;2.5&lt;/TD&gt;&lt;TD&gt;456&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;7&lt;/TD&gt;&lt;TD&gt;2002&lt;/TD&gt;&lt;TD&gt;3.5&lt;/TD&gt;&lt;TD&gt;456&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;8&lt;/TD&gt;&lt;TD&gt;2003&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;TD&gt;456&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;9&lt;/TD&gt;&lt;TD&gt;2009&lt;/TD&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;789&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;10&lt;/TD&gt;&lt;TD&gt;2010&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;TD&gt;789&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;11&lt;/TD&gt;&lt;TD&gt;2006&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;TD&gt;1011&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;BR /&gt;I am looking for employees (EMP NO.)&amp;nbsp; where at some point they had a DISCSCORE of 5 but then in subsequent years, they received any other score.&amp;nbsp; So, drawing the example from my dataset above, the syntax would return Emp No. 123 because they had a discscore of 5 in 2006 and then received a 0.5 in 2007.&amp;nbsp; The syntax would NOT return Emp No.'s 456, 789 or 1011 because the last Discscore they received were 5s.&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 17 Feb 2012 21:16:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Looking-for-exceptions/m-p/58034#M16206</guid>
      <dc:creator>Noelle125</dc:creator>
      <dc:date>2012-02-17T21:16:12Z</dc:date>
    </item>
    <item>
      <title>Looking for exceptions</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Looking-for-exceptions/m-p/58035#M16207</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What do you plan to do the cases with 5 then 0.5 then get back to 5 again?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 17 Feb 2012 21:31:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Looking-for-exceptions/m-p/58035#M16207</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2012-02-17T21:31:22Z</dc:date>
    </item>
    <item>
      <title>Looking for exceptions</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Looking-for-exceptions/m-p/58036#M16208</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;A self join should do:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;input incidentId year discScore EmpNo;&lt;/P&gt;&lt;P&gt;datalines;&lt;/P&gt;&lt;P&gt;1 2005 2 123 &lt;/P&gt;&lt;P&gt;2 2006 5 123 &lt;/P&gt;&lt;P&gt;3 2007 0.5 123 &lt;/P&gt;&lt;P&gt;4 2008 1 123 &lt;/P&gt;&lt;P&gt;5 2009 1.5 123 &lt;/P&gt;&lt;P&gt;6 2001 2.5 456 &lt;/P&gt;&lt;P&gt;7 2002 3.5 456 &lt;/P&gt;&lt;P&gt;8 2003 5 456 &lt;/P&gt;&lt;P&gt;9 2009 4 789 &lt;/P&gt;&lt;P&gt;10 2010 5 789 &lt;/P&gt;&lt;P&gt;11 2006 5 1011 &lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;create table want as&lt;/P&gt;&lt;P&gt;select unique a.empNo&lt;/P&gt;&lt;P&gt;from have as a inner join have as b &lt;/P&gt;&lt;P&gt;on a.empNo=b.empNo and a.year&amp;gt;b.year&lt;/P&gt;&lt;P&gt;where b.discScore&amp;gt;=5;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PG&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 17 Feb 2012 21:37:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Looking-for-exceptions/m-p/58036#M16208</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2012-02-17T21:37:33Z</dc:date>
    </item>
    <item>
      <title>Looking for exceptions</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Looking-for-exceptions/m-p/58037#M16209</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; Good question.&amp;nbsp; That situation does exist in the dataset.&amp;nbsp; Ideally, those would be flagged as well but I believe those are truly rare and so if they, too, were returned, I would deal with them manually.&amp;nbsp; Obviously, it is easy to find all the 5s.&amp;nbsp; I'm just trying to not have to manually look through thousands of records to find those cases where an employee received a 5 and then received some other score later on.&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 17 Feb 2012 21:40:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Looking-for-exceptions/m-p/58037#M16209</guid>
      <dc:creator>Noelle125</dc:creator>
      <dc:date>2012-02-17T21:40:30Z</dc:date>
    </item>
    <item>
      <title>Looking for exceptions</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Looking-for-exceptions/m-p/58038#M16210</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; Thank you.&amp;nbsp; This is very helpful as I know next to nothing about SQL.&amp;nbsp; I will try this right now.&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 17 Feb 2012 21:45:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Looking-for-exceptions/m-p/58038#M16210</guid>
      <dc:creator>Noelle125</dc:creator>
      <dc:date>2012-02-17T21:45:05Z</dc:date>
    </item>
    <item>
      <title>Looking for exceptions</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Looking-for-exceptions/m-p/58039#M16211</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here is a way to do it with a datastep:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sort data=have;&lt;/P&gt;&lt;P&gt;&amp;nbsp; by Emp_No Year;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want (keep=Emp_No);&lt;/P&gt;&lt;P&gt;&amp;nbsp; set have;&lt;/P&gt;&lt;P&gt;&amp;nbsp; by Emp_No;&lt;/P&gt;&lt;P&gt;&amp;nbsp; retain have5 want;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if first.Emp_No then do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; have5=0;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; want=0;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if have5 and Discscore ne 5 then want=1;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if Discscore eq 5 then have5=1;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if last.Emp_no and have5 and want&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; then output;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 17 Feb 2012 21:45:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Looking-for-exceptions/m-p/58039#M16211</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2012-02-17T21:45:45Z</dc:date>
    </item>
    <item>
      <title>Looking for exceptions</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Looking-for-exceptions/m-p/58040#M16212</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Well, this will only take care of 1. there were incidence of '5'. 2.The last of group is not '5'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; data have;&lt;/P&gt;&lt;P&gt; infile cards;&lt;/P&gt;&lt;P&gt; input IncidentID&amp;nbsp;&amp;nbsp;&amp;nbsp; Year&amp;nbsp;&amp;nbsp;&amp;nbsp; Discscore&amp;nbsp;&amp;nbsp;&amp;nbsp; Empno;&lt;/P&gt;&lt;P&gt; cards;&lt;/P&gt;&lt;P&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp; 2005&amp;nbsp;&amp;nbsp;&amp;nbsp; 2&amp;nbsp;&amp;nbsp;&amp;nbsp; 123&lt;/P&gt;&lt;P&gt;2&amp;nbsp;&amp;nbsp;&amp;nbsp; 2006&amp;nbsp;&amp;nbsp;&amp;nbsp; 5&amp;nbsp;&amp;nbsp;&amp;nbsp; 123&lt;/P&gt;&lt;P&gt;3&amp;nbsp;&amp;nbsp;&amp;nbsp; 2007&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.5&amp;nbsp;&amp;nbsp;&amp;nbsp; 123&lt;/P&gt;&lt;P&gt;4&amp;nbsp;&amp;nbsp;&amp;nbsp; 2008&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp; 123&lt;/P&gt;&lt;P&gt;5&amp;nbsp;&amp;nbsp;&amp;nbsp; 2009&amp;nbsp;&amp;nbsp;&amp;nbsp; 1.5&amp;nbsp;&amp;nbsp;&amp;nbsp; 123&lt;/P&gt;&lt;P&gt;6&amp;nbsp;&amp;nbsp;&amp;nbsp; 2001&amp;nbsp;&amp;nbsp;&amp;nbsp; 2.5&amp;nbsp;&amp;nbsp;&amp;nbsp; 456&lt;/P&gt;&lt;P&gt;7&amp;nbsp;&amp;nbsp;&amp;nbsp; 2002&amp;nbsp;&amp;nbsp;&amp;nbsp; 3.5&amp;nbsp;&amp;nbsp;&amp;nbsp; 456&lt;/P&gt;&lt;P&gt;8&amp;nbsp;&amp;nbsp;&amp;nbsp; 2003&amp;nbsp;&amp;nbsp;&amp;nbsp; 5&amp;nbsp;&amp;nbsp;&amp;nbsp; 456&lt;/P&gt;&lt;P&gt;9&amp;nbsp;&amp;nbsp;&amp;nbsp; 2009&amp;nbsp;&amp;nbsp;&amp;nbsp; 4&amp;nbsp;&amp;nbsp;&amp;nbsp; 789&lt;/P&gt;&lt;P&gt;10&amp;nbsp;&amp;nbsp;&amp;nbsp; 2010&amp;nbsp;&amp;nbsp;&amp;nbsp; 5&amp;nbsp;&amp;nbsp;&amp;nbsp; 789&lt;/P&gt;&lt;P&gt;11&amp;nbsp;&amp;nbsp;&amp;nbsp; 2006&amp;nbsp;&amp;nbsp;&amp;nbsp; 5&amp;nbsp;&amp;nbsp;&amp;nbsp; 1011&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want (keep=empno);&lt;/P&gt;&lt;P&gt;do until (last.empno);&lt;/P&gt;&lt;P&gt;set have;&lt;/P&gt;&lt;P&gt;by empno year;&lt;/P&gt;&lt;P&gt;if first.empno then _f=0;&lt;/P&gt;&lt;P&gt;if discscore=5 then _f=1;&lt;/P&gt;&lt;P&gt;if last.empno then _f1=(discscore&amp;lt;5);&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;if _f*_f1=1 then output;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc print;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Will look into more general approach. I hope this will get you started.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Haikuo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 17 Feb 2012 21:47:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Looking-for-exceptions/m-p/58040#M16212</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2012-02-17T21:47:16Z</dc:date>
    </item>
    <item>
      <title>Looking for exceptions</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Looking-for-exceptions/m-p/58041#M16213</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; Thank you!&amp;nbsp; You have given me another thing to try.&amp;nbsp; I really appreciate this.&amp;nbsp; For whatever reason, I was really stumped by this seemingly simple issue.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 17 Feb 2012 21:51:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Looking-for-exceptions/m-p/58041#M16213</guid>
      <dc:creator>Noelle125</dc:creator>
      <dc:date>2012-02-17T21:51:58Z</dc:date>
    </item>
    <item>
      <title>Looking for exceptions</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Looking-for-exceptions/m-p/58042#M16214</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; ﻿Thank you!&amp;nbsp; This will definitely get me started.&amp;nbsp; Again, I truly appreciate all of the help.&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 17 Feb 2012 21:53:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Looking-for-exceptions/m-p/58042#M16214</guid>
      <dc:creator>Noelle125</dc:creator>
      <dc:date>2012-02-17T21:53:25Z</dc:date>
    </item>
    <item>
      <title>Looking for exceptions</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Looking-for-exceptions/m-p/58043#M16215</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This will take care of those fluctuated cases as well, it will first check if there is '5', and if yes, then check if there is '&amp;lt;5' after within the same group.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want (keep=empno);&lt;/P&gt;&lt;P&gt;do until (last.empno);&lt;/P&gt;&lt;P&gt;set have;&lt;/P&gt;&lt;P&gt;by empno year;&lt;/P&gt;&lt;P&gt;if discscore=5 then _f=1;&lt;/P&gt;&lt;P&gt;if _f=1 and discscore &amp;lt; 5 then _f1=1;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;if _f*_f1 then output;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;HTH,&lt;/P&gt;&lt;P&gt;Haikuo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 17 Feb 2012 21:58:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Looking-for-exceptions/m-p/58043#M16215</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2012-02-17T21:58:46Z</dc:date>
    </item>
    <item>
      <title>Looking for exceptions</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Looking-for-exceptions/m-p/58044#M16216</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; Wow!&amp;nbsp; Thank you!&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 17 Feb 2012 22:15:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Looking-for-exceptions/m-p/58044#M16216</guid>
      <dc:creator>Noelle125</dc:creator>
      <dc:date>2012-02-17T22:15:23Z</dc:date>
    </item>
    <item>
      <title>Looking for exceptions</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Looking-for-exceptions/m-p/58045#M16217</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;input incidentId year discScore EmpNo;&lt;/P&gt;&lt;P&gt;datalines;&lt;/P&gt;&lt;P&gt;1 2005 2 123&lt;/P&gt;&lt;P&gt;2 2006 5 123&lt;/P&gt;&lt;P&gt;3 2007 0.5 123&lt;/P&gt;&lt;P&gt;4 2008 1 123&lt;/P&gt;&lt;P&gt;5 2009 1.5 123&lt;/P&gt;&lt;P&gt;6 2001 2.5 456&lt;/P&gt;&lt;P&gt;7 2002 3.5 456&lt;/P&gt;&lt;P&gt;8 2003 5 456&lt;/P&gt;&lt;P&gt;9 2009 4 789&lt;/P&gt;&lt;P&gt;10 2010 5 789&lt;/P&gt;&lt;P&gt;11 2006 5 1011&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;create table want as&lt;/P&gt;&lt;P&gt;&amp;nbsp; select distinct a.empno&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; from have&amp;nbsp; a, have&amp;nbsp; b&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; where (a.empNo=b.empNo) and a.discscore&amp;gt;=5 and (a.year&amp;lt;b.year);&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;proc print;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 18 Feb 2012 00:36:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Looking-for-exceptions/m-p/58045#M16217</guid>
      <dc:creator>Linlin</dc:creator>
      <dc:date>2012-02-18T00:36:48Z</dc:date>
    </item>
    <item>
      <title>Looking for exceptions</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Looking-for-exceptions/m-p/58046#M16218</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;PGstats and Linlin,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SQL works for OP's as-is data, however, multiple adjacent '5's within one group will also be pulled. Check this out:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;input incidentId year discScore EmpNo;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;datalines;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1 2005 2 123&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2 2006 5 123&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3 2007 0.5 123&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;4 2008 1 123&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;5 2009 1.5 123&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;6 2001 2.5 456&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;7 2002 3.5 456&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;8 2003 5 456&lt;/P&gt;&lt;P&gt;8.1 2004 5 456&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;9 2009 4 789&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;10 2010 5 789&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;11 2006 5 1011&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;in this case, '456' will also be pulled, even there is no '&amp;lt;5' existing after '5'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kindly Regards,&lt;/P&gt;&lt;P&gt;Haikuo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 18 Feb 2012 01:03:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Looking-for-exceptions/m-p/58046#M16218</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2012-02-18T01:03:01Z</dc:date>
    </item>
    <item>
      <title>Looking for exceptions</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Looking-for-exceptions/m-p/58047#M16219</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You are perfectly right Hai.kuo, there was a clause missing in my SQL query and the equivalent one from Linlin. As we fix this, we can also fix the problem of a sequence hitting discScore=5 many times, as illustrated below. I think the query would be most useful if it read :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data have;&lt;BR /&gt;input incidentId year discScore EmpNo;&lt;BR /&gt;datalines;&lt;BR /&gt;1 2005 2 123&lt;BR /&gt;2 2006 5 123&lt;BR /&gt;3 2007 0.5 123&lt;BR /&gt;4 2008 1 123&lt;BR /&gt;5 2009 1.5 123&lt;BR /&gt;6 2001 2.5 456&lt;BR /&gt;7 2002 3.5 456&lt;BR /&gt;8 2003 5 456&lt;BR /&gt;8.1 2004 5 456&lt;BR /&gt;9 2009 4 789&lt;BR /&gt;10 2010 5 789&lt;BR /&gt;10.1 2011 3 789&lt;BR /&gt;10.2 2012 5 789&lt;BR /&gt;10.3 2013 0.5 789&lt;BR /&gt;11 2006 5 1011&lt;BR /&gt;;&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;create table want as&lt;BR /&gt;select unique b.incidentId, b.year, b.empNo&lt;BR /&gt;from have as a inner join have as b &lt;BR /&gt;on a.empNo = b.empNo and &lt;BR /&gt;&amp;nbsp;&amp;nbsp; a.year &amp;gt; b.year and &lt;BR /&gt;&amp;nbsp;&amp;nbsp; a.discScore ne b.discScore&lt;BR /&gt;where b.discScore &amp;gt;= 5;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc print; run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then every case where a series of scores hits 5 followed later by some other score would be pulled out. Given the problem statement, it is not clear if the extra condition should read &lt;EM&gt;a.discScore ne b.discScore&lt;/EM&gt; (other score, as stated) or &lt;EM&gt;a.discScore &amp;lt; b.discScore&lt;/EM&gt; (lower score, as was possibly meant)&lt;EM&gt;.&lt;/EM&gt; Of course, if the maximum score is 5, then both conditions are equivalent.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PG&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 18 Feb 2012 03:27:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Looking-for-exceptions/m-p/58047#M16219</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2012-02-18T03:27:46Z</dc:date>
    </item>
    <item>
      <title>Looking for exceptions</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Looking-for-exceptions/m-p/58048#M16220</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If I understood what you mean.&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 have;
input incidentId year discScore EmpNo;
datalines;
1 2005 2 123
2 2006 5 123
3 2007 0.5 123
4 2008 1 123
5 2009 1.5 123
6 2001 2.5 456
7 2002 3.5 456
8 2003 5 456
9 2004 5 456
10 2009 4 789
11 2010 5 789
12 2006 5 1011
;
run;
proc sql;
 create table want as
&amp;nbsp; select distinct empno
&amp;nbsp;&amp;nbsp; from have as a
&amp;nbsp;&amp;nbsp;&amp;nbsp; where discscore=5
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; having (select count(*) from have where empno=a.empno and year gt a.year) gt 0;
quit;


&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;&lt;/P&gt;&lt;P&gt;Ksharp&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Feb 2012 06:56:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Looking-for-exceptions/m-p/58048#M16220</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2012-02-20T06:56:28Z</dc:date>
    </item>
  </channel>
</rss>

