data ds;
length emp_name $20;
input emp_name $ dep_id salary;
datalines;
Siva 1 30000
Ravi 2 40000
Prasad 1 50000
Arun 1 30000
Sai 2 20000
;
run;
proc sql;
create table _temp as
select dep_id,max(salary) as max_sal ,min(salary) as min_sal
from ds
group by dep_id ;
create table _temp as
select a.* ,b.emp_name as emp_name_min,c.emp_name as emp_name_max
from _temp as a
left join ds as b
on a.min_sal=b.salary
left join ds as c
on a.max_sal=c.salary;
quit;
proc sort data=_temp nodupkey ;
by dep_id;
run;
proc print;
run;
How to get min and max salary for each dept_id using proc sql and datastep in the above code result I got only one minsalary from dep_id 1 but given data two min salary are same how to fix this
... View more