Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


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



how to get second highest salary from a employee table and how get a 5th highest salary from a empl..

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

how to get second highest salary from a employee table and how get a 5th highest salary from a empl..

Answer / dinesh

select * from emp e where
2 =(select count(distinct sal) from emp where e.sal<=sal)
or 5=(select count(distinct sal) from emp where e.sal<=sal);

Is This Answer Correct ?    9 Yes 5 No

how to get second highest salary from a employee table and how get a 5th highest salary from a empl..

Answer / na

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

how to get second highest salary from a employee table and how get a 5th highest salary from a empl..

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

how to get second highest salary from a employee table and how get a 5th highest salary from a empl..

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

how to get second highest salary from a employee table and how get a 5th highest salary from a empl..

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

how to get second highest salary from a employee table and how get a 5th highest salary from a empl..

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

how to get second highest salary from a employee table and how get a 5th highest salary from a empl..

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

how to get second highest salary from a employee table and how get a 5th highest salary from a empl..

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

how to get second highest salary from a employee table and how get a 5th highest salary from a empl..

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

Post New Answer

More SAS Interview Questions

How do you specify the number of iterations and specific condition within a single do loop?

0 Answers  


what is null hypothesis? why do you consider that?

0 Answers   Accenture, Quintiles,


what are the different ways of merging two datasets.name atleast 4.

2 Answers  


Why double trailing @@ is used in input statement?

0 Answers  


What are the limitations for memory allocation for SAS variables

0 Answers   Signetsoft,


what is washout period?

3 Answers   Cognizant,


What are the joins,types of joins and thier functions?

7 Answers   SAS,


how does sas handle missing values in assignment statements? : Sas programming

0 Answers  


What are symbol tables?Differemce between Local N Global Symbol tables.....

2 Answers   TCS,


1.we can execute a macro with in a macro,by using call symput and symget can any one give me one example? 2.We can create the macro variables by using %let,%do,macro parameters,INTO clause in proc sql and call symput, can any one give me example to create macro variable with INTO clause and call symput? 3.

1 Answers  


how to perform paired t-test using Base/SAS & SAS/Stat?

2 Answers  


What are the five ways to do a table lookup in sas? : sas-grid-administration

0 Answers  


Categories