<?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 warning not correct output in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/warning-not-correct-output/m-p/628442#M77542</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data req;
input id$ salary;
datalines;
001 2000
002 3000
003 4000
001 3000
001 5000
004 2000
003 1000
002 5000
004 1000
run;
how to get second hightest salary group by id;
 *correct program;
proc sql;
create table want as select*,largest(2,salary)
from req
group by id;
quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;135 proc sql;&lt;BR /&gt;136 create table want as select*,largest(2,salary)&lt;BR /&gt;137 from req&lt;BR /&gt;138 group by id;&lt;BR /&gt;WARNING: A GROUP BY clause has been transformed into an ORDER BY clause because neither&lt;BR /&gt;the SELECT clause nor the optional HAVING clause of the associated&lt;BR /&gt;table-expression referenced a summary function.&lt;BR /&gt;NOTE: Invalid argument 1 to function LARGEST. Missing values may be generated.&lt;BR /&gt;NOTE: Table WORK.WANT created, with 9 rows and 3 columns.&lt;/P&gt;&lt;P&gt;139 quit;&lt;BR /&gt;NOTE: PROCEDURE SQL used (Total process time):&lt;BR /&gt;real time 0.15 seconds&lt;BR /&gt;cpu time 0.04 seconds&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;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 29 Feb 2020 14:45:16 GMT</pubDate>
    <dc:creator>BrahmanandaRao</dc:creator>
    <dc:date>2020-02-29T14:45:16Z</dc:date>
    <item>
      <title>warning not correct output</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/warning-not-correct-output/m-p/628442#M77542</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data req;
input id$ salary;
datalines;
001 2000
002 3000
003 4000
001 3000
001 5000
004 2000
003 1000
002 5000
004 1000
run;
how to get second hightest salary group by id;
 *correct program;
proc sql;
create table want as select*,largest(2,salary)
from req
group by id;
quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;135 proc sql;&lt;BR /&gt;136 create table want as select*,largest(2,salary)&lt;BR /&gt;137 from req&lt;BR /&gt;138 group by id;&lt;BR /&gt;WARNING: A GROUP BY clause has been transformed into an ORDER BY clause because neither&lt;BR /&gt;the SELECT clause nor the optional HAVING clause of the associated&lt;BR /&gt;table-expression referenced a summary function.&lt;BR /&gt;NOTE: Invalid argument 1 to function LARGEST. Missing values may be generated.&lt;BR /&gt;NOTE: Table WORK.WANT created, with 9 rows and 3 columns.&lt;/P&gt;&lt;P&gt;139 quit;&lt;BR /&gt;NOTE: PROCEDURE SQL used (Total process time):&lt;BR /&gt;real time 0.15 seconds&lt;BR /&gt;cpu time 0.04 seconds&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;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 29 Feb 2020 14:45:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/warning-not-correct-output/m-p/628442#M77542</guid>
      <dc:creator>BrahmanandaRao</dc:creator>
      <dc:date>2020-02-29T14:45:16Z</dc:date>
    </item>
    <item>
      <title>Re: warning not correct output</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/warning-not-correct-output/m-p/628444#M77543</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/265860"&gt;@BrahmanandaRao&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is an approach to do this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
	create table want as
	select id, max(salary) as max2
	from (select * from req group by id having salary &amp;lt; max(salary))
	group by id;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I am not sure whether you can use the largest() function in proc sql.&lt;/P&gt;</description>
      <pubDate>Sat, 29 Feb 2020 15:01:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/warning-not-correct-output/m-p/628444#M77543</guid>
      <dc:creator>ed_sas_member</dc:creator>
      <dc:date>2020-02-29T15:01:53Z</dc:date>
    </item>
    <item>
      <title>Re: warning not correct output</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/warning-not-correct-output/m-p/628445#M77544</link>
      <description>&lt;P&gt;Another approach could be:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=req;
	by id;
run;

proc transpose data=req out=req_tr prefix=salary;
	var salary;
	by id;
run;

data want;
	set req_tr;
	max2 = largest(2,of salary:);
	keep id max2;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 29 Feb 2020 15:02:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/warning-not-correct-output/m-p/628445#M77544</guid>
      <dc:creator>ed_sas_member</dc:creator>
      <dc:date>2020-02-29T15:02:34Z</dc:date>
    </item>
    <item>
      <title>Re: warning not correct output</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/warning-not-correct-output/m-p/628454#M77545</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
	set req_tr;
	max2 = largest(2,of salary:);
	keep id max2;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;NOTE: Argument 1 to function LARGEST(2,2000) at line 178 column 9 is invalid.&lt;BR /&gt;id=001 salary=2000 max2=. _ERROR_=1 _N_=1&lt;BR /&gt;NOTE: Argument 1 to function LARGEST(2,3000) at line 178 column 9 is invalid.&lt;BR /&gt;id=002 salary=3000 max2=. _ERROR_=1 _N_=2&lt;BR /&gt;NOTE: Argument 1 to function LARGEST(2,4000) at line 178 column 9 is invalid.&lt;BR /&gt;id=003 salary=4000 max2=. _ERROR_=1 _N_=3&lt;BR /&gt;NOTE: Argument 1 to function LARGEST(2,3000) at line 178 column 9 is invalid.&lt;BR /&gt;id=001 salary=3000 max2=. _ERROR_=1 _N_=4&lt;BR /&gt;NOTE: Argument 1 to function LARGEST(2,5000) at line 178 column 9 is invalid.&lt;BR /&gt;id=001 salary=5000 max2=. _ERROR_=1 _N_=5&lt;BR /&gt;NOTE: Argument 1 to function LARGEST(2,2000) at line 178 column 9 is invalid.&lt;BR /&gt;id=004 salary=2000 max2=. _ERROR_=1 _N_=6&lt;BR /&gt;NOTE: Argument 1 to function LARGEST(2,1000) at line 178 column 9 is invalid.&lt;BR /&gt;id=003 salary=1000 max2=. _ERROR_=1 _N_=7&lt;BR /&gt;NOTE: Argument 1 to function LARGEST(2,5000) at line 178 column 9 is invalid.&lt;BR /&gt;id=002 salary=5000 max2=. _ERROR_=1 _N_=8&lt;BR /&gt;NOTE: Argument 1 to function LARGEST(2,1000) at line 178 column 9 is invalid.&lt;BR /&gt;id=004 salary=1000 max2=. _ERROR_=1 _N_=9&lt;BR /&gt;NOTE: Mathematical operations could not be performed at the following places. The results&lt;BR /&gt;of the operations have been set to missing values.&lt;BR /&gt;Each place is given by: (Number of times) at (Line):(Column).&lt;BR /&gt;9 at 178:9&lt;BR /&gt;NOTE: There were 9 observations read from the data set WORK.REQ.&lt;BR /&gt;NOTE: The data set WORK.WANT has 9 observations and 2 variables.&lt;BR /&gt;NOTE: DATA statement used (Total process time):&lt;BR /&gt;real time 0.01 seconds&lt;BR /&gt;cpu time 0.01 seconds&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 29 Feb 2020 15:57:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/warning-not-correct-output/m-p/628454#M77545</guid>
      <dc:creator>BrahmanandaRao</dc:creator>
      <dc:date>2020-02-29T15:57:04Z</dc:date>
    </item>
    <item>
      <title>Re: warning not correct output</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/warning-not-correct-output/m-p/628511#M77548</link>
      <description>&lt;P&gt;You only want SQL ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data req;
input id$ salary;
datalines;
001 2000
002 3000
003 4000
001 3000
001 5000
004 2000
003 1000
002 5000
004 1000
;

proc sql;
select distinct a.*
 from req as a,req as b
  where a.id=b.id and a.salary&amp;lt;b.salary 
   group by a.id,a.salary 
    having count(*)=1;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 01 Mar 2020 04:22:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/warning-not-correct-output/m-p/628511#M77548</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2020-03-01T04:22:37Z</dc:date>
    </item>
  </channel>
</rss>

