<?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: Proc sql finding Max value in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Proc-sql-finding-Max-value/m-p/246820#M46241</link>
    <description>&lt;P&gt;You want select the second large Salary OBS ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&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 have;
input id Salary;
cards;
101 1000
102 2000
103 1000
104 3000
105 3000
106 4000
;
proc sql;
select id, salary ,(select count(distinct salary) from have where salary lt a.salary) as n
from have as a
where calculated n=1;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 29 Jan 2016 02:46:07 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2016-01-29T02:46:07Z</dc:date>
    <item>
      <title>Proc sql finding Max value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-sql-finding-Max-value/m-p/246595#M46160</link>
      <description>&lt;P&gt;&lt;BR /&gt;data have;&lt;BR /&gt;input id Salary;&lt;BR /&gt;cards;&lt;BR /&gt;101 1000&lt;BR /&gt;102 2000&lt;BR /&gt;103 1000&lt;BR /&gt;104 3000&lt;BR /&gt;105 3000&lt;BR /&gt;106 4000&lt;BR /&gt;;&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;create table want as&lt;BR /&gt;select id, max( salary ) as wantvar&lt;BR /&gt;from have&lt;BR /&gt;where salary &amp;lt; ( select max( salary ) from have where salary &amp;lt; ( select max ( salary ) from have));&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;above code is giving 3 records... it should get only one that is&amp;nbsp;&lt;SPAN&gt;102 2000.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Please help.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 28 Jan 2016 12:24:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-sql-finding-Max-value/m-p/246595#M46160</guid>
      <dc:creator>vandhan</dc:creator>
      <dc:date>2016-01-28T12:24:32Z</dc:date>
    </item>
    <item>
      <title>Re: Proc sql finding Max value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-sql-finding-Max-value/m-p/246596#M46161</link>
      <description>&lt;P&gt;You already posted this in general SAS Programming. Please refrain from double posting.&lt;/P&gt;</description>
      <pubDate>Thu, 28 Jan 2016 12:25:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-sql-finding-Max-value/m-p/246596#M46161</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-01-28T12:25:30Z</dc:date>
    </item>
    <item>
      <title>Re: Proc sql finding Max value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-sql-finding-Max-value/m-p/246820#M46241</link>
      <description>&lt;P&gt;You want select the second large Salary OBS ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&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 have;
input id Salary;
cards;
101 1000
102 2000
103 1000
104 3000
105 3000
106 4000
;
proc sql;
select id, salary ,(select count(distinct salary) from have where salary lt a.salary) as n
from have as a
where calculated n=1;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 29 Jan 2016 02:46:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-sql-finding-Max-value/m-p/246820#M46241</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-01-29T02:46:07Z</dc:date>
    </item>
  </channel>
</rss>

