<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to find the Nth largest salary from a sas dataset using Proc SQL in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-the-Nth-largest-salary-from-a-sas-dataset-using-Proc/m-p/826388#M326416</link>
    <description>&lt;P&gt;The question was to find a&amp;nbsp;&lt;EM&gt;single&lt;/EM&gt; value, which my code does. See Maxim 42 &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 01 Aug 2022 05:18:11 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2022-08-01T05:18:11Z</dc:date>
    <item>
      <title>How to find the Nth largest salary from a sas dataset using Proc SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-the-Nth-largest-salary-from-a-sas-dataset-using-Proc/m-p/226415#M40745</link>
      <description>&lt;P&gt;How to find the Nth largest salary from a sas dataset using Proc SQL?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;EMPNO Salary empcode&lt;/P&gt;&lt;P&gt;111 4000 A&lt;BR /&gt;112 6000 A&lt;BR /&gt;114 2000 A&lt;BR /&gt;115 8000 A&lt;BR /&gt;223 2000 B&lt;BR /&gt;226 1000 B&lt;BR /&gt;228 3000 B&lt;BR /&gt;300 500 C&lt;BR /&gt;333 700 C&lt;BR /&gt;345 300 C&lt;BR /&gt;356 200 C&lt;BR /&gt;320 700 C&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;i want to find out the 3rd largest salary group by empcode using Proc Sql.&lt;/P&gt;</description>
      <pubDate>Sat, 19 Sep 2015 10:04:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-find-the-Nth-largest-salary-from-a-sas-dataset-using-Proc/m-p/226415#M40745</guid>
      <dc:creator>harpaljosan</dc:creator>
      <dc:date>2015-09-19T10:04:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to find the Nth largest salary from a sas dataset using Proc SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-the-Nth-largest-salary-from-a-sas-dataset-using-Proc/m-p/226417#M40746</link>
      <description>&lt;P&gt;I really suggest you to use data step , NOT Sql.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input EMPNO Salary empcode $;
cards;
111 4000 A
112 6000 A
114 2000 A
115 8000 A
223 2000 B
226 1000 B
228 3000 B
300 500 C
333 700 C
345 300 C
356 200 C
320 700 C
;
run;
proc sql;
create table want as
 select *,
  (select count(*) from 
    (select distinct Salary,empcode from have) as b 
   where b.empcode=a.empcode and b.Salary gt a.Salary) as n
  from have as a
   where calculated n=2;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 19 Sep 2015 10:55:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-find-the-Nth-largest-salary-from-a-sas-dataset-using-Proc/m-p/226417#M40746</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2015-09-19T10:55:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to find the Nth largest salary from a sas dataset using Proc SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-the-Nth-largest-salary-from-a-sas-dataset-using-Proc/m-p/226420#M40747</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=have;
by descending salary;
run;

data want;
set have;
if _n_ = &lt;FONT color="#FF0000"&gt;&lt;EM&gt;number_you_want&lt;/EM&gt;&lt;/FONT&gt; then do;
  output;
  stop;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;BR /&gt;Absolutely no need for SQL.&lt;/P&gt;</description>
      <pubDate>Sat, 19 Sep 2015 11:18:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-find-the-Nth-largest-salary-from-a-sas-dataset-using-Proc/m-p/226420#M40747</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2015-09-19T11:18:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to find the Nth largest salary from a sas dataset using Proc SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-the-Nth-largest-salary-from-a-sas-dataset-using-Proc/m-p/226424#M40748</link>
      <description>&lt;P&gt;PROC RANK will do this as well.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I agree with the others, it is really pointless to insist on doing this in PROC SQL&lt;/P&gt;</description>
      <pubDate>Sat, 19 Sep 2015 12:25:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-find-the-Nth-largest-salary-from-a-sas-dataset-using-Proc/m-p/226424#M40748</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2015-09-19T12:25:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to find the Nth largest salary from a sas dataset using Proc SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-the-Nth-largest-salary-from-a-sas-dataset-using-Proc/m-p/826387#M326415</link>
      <description>&lt;P&gt;this program will not work if there are multiple salaries with the same value.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 01 Aug 2022 05:09:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-find-the-Nth-largest-salary-from-a-sas-dataset-using-Proc/m-p/826387#M326415</guid>
      <dc:creator>sas_guru</dc:creator>
      <dc:date>2022-08-01T05:09:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to find the Nth largest salary from a sas dataset using Proc SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-the-Nth-largest-salary-from-a-sas-dataset-using-Proc/m-p/826388#M326416</link>
      <description>&lt;P&gt;The question was to find a&amp;nbsp;&lt;EM&gt;single&lt;/EM&gt; value, which my code does. See Maxim 42 &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 01 Aug 2022 05:18:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-find-the-Nth-largest-salary-from-a-sas-dataset-using-Proc/m-p/826388#M326416</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-08-01T05:18:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to find the Nth largest salary from a sas dataset using Proc SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-the-Nth-largest-salary-from-a-sas-dataset-using-Proc/m-p/826391#M326417</link>
      <description>&lt;P&gt;But the data step can easily be adapted to deal with groups:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have;
by salary;
if first.salary then n + 1;
if n &amp;gt; number_you_want then stop;
if n = number_you_want;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 01 Aug 2022 05:36:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-find-the-Nth-largest-salary-from-a-sas-dataset-using-Proc/m-p/826391#M326417</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-08-01T05:36:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to find the Nth largest salary from a sas dataset using Proc SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-the-Nth-largest-salary-from-a-sas-dataset-using-Proc/m-p/826422#M326429</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/427502"&gt;@sas_guru&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;this program will not work if there are multiple salaries with the same value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;As I said above, PROC RANK is the tool to use, it will find multiple salary values with the same values.&lt;/P&gt;</description>
      <pubDate>Mon, 01 Aug 2022 12:18:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-find-the-Nth-largest-salary-from-a-sas-dataset-using-Proc/m-p/826422#M326429</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-08-01T12:18:24Z</dc:date>
    </item>
  </channel>
</rss>

