how to get second highest salary from a employee table and
how get a 5th highest salary from a employee table?
Answers were Sorted based on User's Feedback
Answer / pricil kurian
/*sort employee table by salary in desending order */
proc sort data=xx nodupkey;
by descending sal ;
run;
/*outputting the second and 5th largest salary to then yy
dataset */
data yy;
set xx;
if _n_ in (2, 5) then output;
run;
| Is This Answer Correct ? | 35 Yes | 13 No |
Proc sql;
Select salary
From
Where salary in (select max
(salary) from
Where salary <(select max
(salary) from
));
Quit;
For second salary
calculation
If salary is not repeted
then
Proc sort data= xxx;
By salary;
Run;
Options firstobs =5;
Proc print data = xxx;
Var salary;
Run;
| Is This Answer Correct ? | 4 Yes | 2 No |
Answer / vidit malhotra
/*Proc RANK method*/
proc rank data=paydept out=order descending ties=dense;
var Salary;
ranks SalaryRank;
run;
proc sql;
select Name,Salary,SalaryRank from order where SalaryRank IN (2,5);
quit;
| Is This Answer Correct ? | 2 Yes | 0 No |
Answer / poorna m
proc sort data=emp out=emp1 nodupkey;
by descending sal empid;
run;
PROC RANK DATA=emp1 OUT=emp3 TIES=LOW DESCENDING;
VAR sal ;
RANKS highestsal;
RUN;
data emp4;
set emp3;
where highestsal in (2,5);
run;
| Is This Answer Correct ? | 1 Yes | 1 No |
Answer / pallavi
proc sort data=xxx;
by descending sal;
run;
proc sql;
select Sal, monotonic() as count
from xxx
having count in(2,5);
quit;
| Is This Answer Correct ? | 3 Yes | 6 No |
Answer / richa
It can be done by first sorting the dataset in the
ascending order of salary and then using the 'point='
option.
For eg:
proc sort data = x;
by salary;
quit;
/*second highest salary*/
data y;
a = 2;
set x point = a;
stop;
run;
/*fifth highest salary*/
data y;
a = 5;
set x point = a;
stop;
run;
| Is This Answer Correct ? | 6 Yes | 10 No |
Answer / vijay
proc sort data=samp out= samp1 nodupkeys;
by sal descending _all_;
run;
/*second highest salary obs will come into samp2 dataset */
/*for fifth highest salary obs change slice value from 2 to 5 */
data samp2;
slice = 2;
set samp1 point = slice;
output;
stop;
run;
| Is This Answer Correct ? | 1 Yes | 7 No |
Answer / beneet kumar pandey
/*second highest salary*/
first select max sal from employee table then select second
max sal from employee table.
Select max(salary) less then(select max(salary) from
employee) from employee;
/*same condition for fifth highest salary*/
| Is This Answer Correct ? | 1 Yes | 8 No |
Answer / nandu
proc sort data=samp nodupkeys;
by sal descending ;
run;
data samp1 samp2;
set samp ;
ln+1 ;
if ln=2 then output samp2 ;
else samp ;
run;
/*second highest salary obs will come into samp2 dataset */
| Is This Answer Correct ? | 3 Yes | 11 No |
What do the PUT and INPUT functions do?
what is the basic structure sas administrator? : Sas-administrator
If reading a variable length file with fixed input, how would you prevent SAS from reading the next record if the last variable didn?t have a value?
I have a dataset with variables empid and doj how to calculate retirement age?
How would you code a macro statement to produce information on the SAS log? This statement can be coded anywhere.
what is in stream data in SAS?
How do you convert basic cube to transaction cube and transaction cube to basic cube?
what techniques and/or procs do you use for tables? : Sas programming
What is the good sas programming practices for processing large data sets?
i have a dataset with 100000 records. i want 100 records from that dataset and create a dataset.we need to pick the observations random order like 100obs,500obs,1020obs,1890obs,2565obs like that i need 100 obs in random order? how can we create this one?
why a stop statement is needed for the point= option on a set statement?
Hi Jeevan/Akshara I have tried to contact SASI Vats for latest Advanced SAS Programming Certification Dumps (A00-212) but have not got any response. I would highly and gratefully appreciate your assistance in this regard. If you guys have access to this, would you be kind enough to forward it to me ? I would abide by all the terms you have for this. Please, note my email id: upretigopi@yahoo.com Preti Sharma