<?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: Find 3rd highest salary in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Find-3rd-highest-salary/m-p/848327#M37022</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input ID name $ Salary;
datalines;
1 AM 1000  
2 AD 40000 
3 AE 50000 
5 AF 50000 
6 AK 15000 
7 AZ 15000 
8 AS 2500  
;
proc sql;
select a.id,a.name,a.Salary,count(distinct b.salary) as n
 from have as a,have as b
  where a.salary&amp;lt;b.salary
   group by a.id,a.name,a.Salary
    having calculated n=2
    order by 1
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 07 Dec 2022 12:03:26 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2022-12-07T12:03:26Z</dc:date>
    <item>
      <title>Find 3rd highest salary</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Find-3rd-highest-salary/m-p/848298#M37010</link>
      <description>&lt;P&gt;Find 3RD highest salary for the below scnario&lt;/P&gt;&lt;P&gt;ID&amp;nbsp; name&amp;nbsp; Salary&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;AM&amp;nbsp; 1000&lt;/P&gt;&lt;P&gt;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;AD&amp;nbsp; &amp;nbsp;40000&lt;/P&gt;&lt;P&gt;3&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;AE&amp;nbsp; &amp;nbsp;50000&lt;/P&gt;&lt;P&gt;5&amp;nbsp; &amp;nbsp; &amp;nbsp; AF&amp;nbsp; &amp;nbsp; &amp;nbsp;50000&lt;/P&gt;&lt;P&gt;6&amp;nbsp; &amp;nbsp; &amp;nbsp;AK&amp;nbsp; &amp;nbsp; 15000&lt;/P&gt;&lt;P&gt;7&amp;nbsp; &amp;nbsp; AS&amp;nbsp; &amp;nbsp; &amp;nbsp;2500&lt;/P&gt;</description>
      <pubDate>Wed, 07 Dec 2022 10:41:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Find-3rd-highest-salary/m-p/848298#M37010</guid>
      <dc:creator>animesh123</dc:creator>
      <dc:date>2022-12-07T10:41:06Z</dc:date>
    </item>
    <item>
      <title>Re: Find 3rd highest salary</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Find-3rd-highest-salary/m-p/848299#M37011</link>
      <description>&lt;P&gt;What if 2 obs have the third highest salary? Do you want both obs?&lt;/P&gt;</description>
      <pubDate>Wed, 07 Dec 2022 10:45:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Find-3rd-highest-salary/m-p/848299#M37011</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2022-12-07T10:45:30Z</dc:date>
    </item>
    <item>
      <title>Re: Find 3rd highest salary</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Find-3rd-highest-salary/m-p/848302#M37012</link>
      <description>if there is a scenario where&lt;BR /&gt;- Required both 2 obs&lt;BR /&gt;- Also 1 OBS</description>
      <pubDate>Wed, 07 Dec 2022 10:50:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Find-3rd-highest-salary/m-p/848302#M37012</guid>
      <dc:creator>animesh123</dc:creator>
      <dc:date>2022-12-07T10:50:35Z</dc:date>
    </item>
    <item>
      <title>Re: Find 3rd highest salary</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Find-3rd-highest-salary/m-p/848303#M37013</link>
      <description>&lt;P&gt;Please post your desired result given this input data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input ID name $ Salary;
datalines;
1 AM 1000  
2 AD 40000
3 AE 50000
5 AF 50000
6 AK 15000
7 AZ 15000
8 AS 2500
;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 07 Dec 2022 10:53:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Find-3rd-highest-salary/m-p/848303#M37013</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2022-12-07T10:53:32Z</dc:date>
    </item>
    <item>
      <title>Re: Find 3rd highest salary</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Find-3rd-highest-salary/m-p/848306#M37014</link>
      <description>&lt;P&gt;Anyways, use Proc Rank and apply the ties option to your liking.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input ID name $ Salary;
datalines;
1 AM 1000  
2 AD 40000 
3 AE 50000 
5 AF 50000 
6 AK 15000 
7 AZ 15000 
8 AS 2500  
;

proc rank data = have out = rank descending ties = dense;
   var Salary;
   ranks r;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 07 Dec 2022 11:03:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Find-3rd-highest-salary/m-p/848306#M37014</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2022-12-07T11:03:13Z</dc:date>
    </item>
    <item>
      <title>Re: Find 3rd highest salary</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Find-3rd-highest-salary/m-p/848307#M37015</link>
      <description>For 2 Obs the output :-&lt;BR /&gt;3 AE 50000&lt;BR /&gt;5 AF 50000&lt;BR /&gt;&lt;BR /&gt;And For 1 Obs the output:&lt;BR /&gt;AF 50000</description>
      <pubDate>Wed, 07 Dec 2022 11:03:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Find-3rd-highest-salary/m-p/848307#M37015</guid>
      <dc:creator>animesh123</dc:creator>
      <dc:date>2022-12-07T11:03:14Z</dc:date>
    </item>
    <item>
      <title>Re: Find 3rd highest salary</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Find-3rd-highest-salary/m-p/848308#M37016</link>
      <description>&lt;P&gt;&lt;SPAN&gt;50000 is not the third highest salary?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Dec 2022 11:04:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Find-3rd-highest-salary/m-p/848308#M37016</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2022-12-07T11:04:11Z</dc:date>
    </item>
    <item>
      <title>Re: Find 3rd highest salary</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Find-3rd-highest-salary/m-p/848310#M37017</link>
      <description>Sorry my bad , If I need to do the same using SQL&lt;BR /&gt;6 AK 15000&lt;BR /&gt;7 AZ 15000</description>
      <pubDate>Wed, 07 Dec 2022 11:07:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Find-3rd-highest-salary/m-p/848310#M37017</guid>
      <dc:creator>animesh123</dc:creator>
      <dc:date>2022-12-07T11:07:01Z</dc:date>
    </item>
    <item>
      <title>Re: Find 3rd highest salary</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Find-3rd-highest-salary/m-p/848313#M37018</link>
      <description>&lt;P&gt;Why does it have to be SQL?&lt;/P&gt;</description>
      <pubDate>Wed, 07 Dec 2022 11:11:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Find-3rd-highest-salary/m-p/848313#M37018</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2022-12-07T11:11:48Z</dc:date>
    </item>
    <item>
      <title>Re: Find 3rd highest salary</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Find-3rd-highest-salary/m-p/848318#M37019</link>
      <description>Its just a question if I need to find out the same using PROC SQL / SQL</description>
      <pubDate>Wed, 07 Dec 2022 11:22:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Find-3rd-highest-salary/m-p/848318#M37019</guid>
      <dc:creator>animesh123</dc:creator>
      <dc:date>2022-12-07T11:22:06Z</dc:date>
    </item>
    <item>
      <title>Re: Find 3rd highest salary</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Find-3rd-highest-salary/m-p/848327#M37022</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input ID name $ Salary;
datalines;
1 AM 1000  
2 AD 40000 
3 AE 50000 
5 AF 50000 
6 AK 15000 
7 AZ 15000 
8 AS 2500  
;
proc sql;
select a.id,a.name,a.Salary,count(distinct b.salary) as n
 from have as a,have as b
  where a.salary&amp;lt;b.salary
   group by a.id,a.name,a.Salary
    having calculated n=2
    order by 1
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 07 Dec 2022 12:03:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Find-3rd-highest-salary/m-p/848327#M37022</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2022-12-07T12:03:26Z</dc:date>
    </item>
    <item>
      <title>Re: Find 3rd highest salary</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Find-3rd-highest-salary/m-p/848330#M37023</link>
      <description>Hey Thanks &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt; . So the Output of the query will be&lt;BR /&gt;6 AK 15000&lt;BR /&gt;7 AZ 15000</description>
      <pubDate>Wed, 07 Dec 2022 12:59:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Find-3rd-highest-salary/m-p/848330#M37023</guid>
      <dc:creator>animesh123</dc:creator>
      <dc:date>2022-12-07T12:59:38Z</dc:date>
    </item>
    <item>
      <title>Re: Find 3rd highest salary</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Find-3rd-highest-salary/m-p/848331#M37024</link>
      <description>Also please explain this&lt;BR /&gt;having calculated n=2&lt;BR /&gt;</description>
      <pubDate>Wed, 07 Dec 2022 13:01:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Find-3rd-highest-salary/m-p/848331#M37024</guid>
      <dc:creator>animesh123</dc:creator>
      <dc:date>2022-12-07T13:01:20Z</dc:date>
    </item>
    <item>
      <title>Re: Find 3rd highest salary</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Find-3rd-highest-salary/m-p/848515#M37048</link>
      <description>It means there are two value greater than the current obs/value (6 AK 15000). &lt;BR /&gt;So the current obs/value is the 3rd highest value.</description>
      <pubDate>Thu, 08 Dec 2022 11:38:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Find-3rd-highest-salary/m-p/848515#M37048</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2022-12-08T11:38:17Z</dc:date>
    </item>
    <item>
      <title>Re: Find 3rd highest salary</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Find-3rd-highest-salary/m-p/848522#M37051</link>
      <description>Thanks &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt; I got it</description>
      <pubDate>Thu, 08 Dec 2022 11:53:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Find-3rd-highest-salary/m-p/848522#M37051</guid>
      <dc:creator>animesh123</dc:creator>
      <dc:date>2022-12-08T11:53:17Z</dc:date>
    </item>
  </channel>
</rss>

