<?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: nth max value in proc sql in Statistical Procedures</title>
    <link>https://communities.sas.com/t5/Statistical-Procedures/nth-max-value-in-proc-sql/m-p/687464#M33142</link>
    <description>&lt;P&gt;Use PROC SORT and a DATA step, or PROC RANK.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PROC SQL is a particularly poor tool for this task.&lt;/P&gt;</description>
    <pubDate>Tue, 29 Sep 2020 11:18:44 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2020-09-29T11:18:44Z</dc:date>
    <item>
      <title>nth max value in proc sql</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/nth-max-value-in-proc-sql/m-p/687460#M33139</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;/P&gt;&lt;P&gt;How to find 4th max value in proc sql&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 10:57:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/nth-max-value-in-proc-sql/m-p/687460#M33139</guid>
      <dc:creator>BrahmanandaRao</dc:creator>
      <dc:date>2020-09-29T10:57:53Z</dc:date>
    </item>
    <item>
      <title>Re: nth max value in proc sql</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/nth-max-value-in-proc-sql/m-p/687464#M33142</link>
      <description>&lt;P&gt;Use PROC SORT and a DATA step, or PROC RANK.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PROC SQL is a particularly poor tool for this task.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 11:18:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/nth-max-value-in-proc-sql/m-p/687464#M33142</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-09-29T11:18:44Z</dc:date>
    </item>
    <item>
      <title>Re: nth max value in proc sql</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/nth-max-value-in-proc-sql/m-p/687466#M33143</link>
      <description>&lt;P&gt;PROC UNIVARIATE will default to outputting the top 5 ranking values and the bottom 5 ranking values, so you might consider it as well.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SteveDenham&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 11:20:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/nth-max-value-in-proc-sql/m-p/687466#M33143</guid>
      <dc:creator>SteveDenham</dc:creator>
      <dc:date>2020-09-29T11:20:31Z</dc:date>
    </item>
    <item>
      <title>Re: nth max value in proc sql</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/nth-max-value-in-proc-sql/m-p/687467#M33144</link>
      <description>Hi PaigeMiller&lt;BR /&gt;in proc sql this cannot solve the problem&lt;BR /&gt;please tell me</description>
      <pubDate>Tue, 29 Sep 2020 11:24:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/nth-max-value-in-proc-sql/m-p/687467#M33144</guid>
      <dc:creator>BrahmanandaRao</dc:creator>
      <dc:date>2020-09-29T11:24:34Z</dc:date>
    </item>
    <item>
      <title>Re: nth max value in proc sql</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/nth-max-value-in-proc-sql/m-p/687470#M33145</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/265860"&gt;@BrahmanandaRao&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Hi PaigeMiller&lt;BR /&gt;in proc sql this cannot solve the problem&lt;BR /&gt;please tell me&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I already told you, PROC SQL is a very poor choice for this problem. The solution is simple using PROC SORT or PROC RANK.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 11:27:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/nth-max-value-in-proc-sql/m-p/687470#M33145</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-09-29T11:27:21Z</dc:date>
    </item>
    <item>
      <title>Re: nth max value in proc sql</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/nth-max-value-in-proc-sql/m-p/687471#M33146</link>
      <description>&lt;P&gt;SQL is not right tool for this.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
 set sashelp.class;
run;
proc sql;
create table want as
select sex,weight,
 (select count(distinct weight) from have where sex=a.sex and weight&amp;gt;=a.weight) as n
 from have as a
  where calculated n=4;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 29 Sep 2020 11:27:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/nth-max-value-in-proc-sql/m-p/687471#M33146</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2020-09-29T11:27:36Z</dc:date>
    </item>
    <item>
      <title>Re: nth max value in proc sql</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/nth-max-value-in-proc-sql/m-p/687480#M33148</link>
      <description>&lt;P&gt;On of the reasons you would want to use PROC RANK and not SQL is that PROC RANK gives you control over how ties are handled, which could be important for real data (although it doesn't matter with SASHELP.CLASS).&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 11:58:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/nth-max-value-in-proc-sql/m-p/687480#M33148</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-09-29T11:58:57Z</dc:date>
    </item>
    <item>
      <title>Re: nth max value in proc sql</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/nth-max-value-in-proc-sql/m-p/687484#M33149</link>
      <description>&lt;P&gt;Get rid of your SQL-itis. Use the right tool.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 12:06:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/nth-max-value-in-proc-sql/m-p/687484#M33149</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-09-29T12:06:11Z</dc:date>
    </item>
    <item>
      <title>Re: nth max value in proc sql</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/nth-max-value-in-proc-sql/m-p/760308#M37044</link>
      <description>&lt;P&gt;Hi K Sharp&lt;/P&gt;
&lt;P&gt;Is it correct method to find nth max value&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _4th;
input id salary;
datalines;
1 2000
2 6000
3 3000
4 9000
5 4500
6 8000
;
run;


proc sql;
create table nmax  as
select id, salary from _4th
order by salary desc
;
select id ,salary from nmax
where monotonic() =4;
quit;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 09 Aug 2021 05:12:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/nth-max-value-in-proc-sql/m-p/760308#M37044</guid>
      <dc:creator>BrahmanandaRao</dc:creator>
      <dc:date>2021-08-09T05:12:43Z</dc:date>
    </item>
    <item>
      <title>Re: nth max value in proc sql</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/nth-max-value-in-proc-sql/m-p/760349#M37048</link>
      <description>No. I would not trust function "monotonic()" .&lt;BR /&gt;It would get the unpredicted result according to sas documentation .&lt;BR /&gt;Pick right tool -&amp;gt; data step .</description>
      <pubDate>Mon, 09 Aug 2021 12:40:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/nth-max-value-in-proc-sql/m-p/760349#M37048</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2021-08-09T12:40:07Z</dc:date>
    </item>
  </channel>
</rss>

