PROC PRINT is just a method to display data.
If you want to calculate sums then use PROC SUMMARY. With PROC SUMMARY you might be able to avoid the original sort and just use a CLASS statement instead of a BY statement.
proc summary data=have nway ;
class employee_id ;
var profit ;
output out=want sum= ;
run;
proc sort data=want ; by descending profit ; run;
proc print;
var profit employee_id;
run;
(or possible roll your own by writing a query using PROC SQL).
proc sql ;
create table want as
select employee_id,sum(profit) as profit
group by 1
order by 2 desc
;
quit;
You could also look at using PROC FREQ and trick it into make a sum by using your PROFIT variable as a WEIGHT variable. But watch out if you have negative or zero values for profit.
proc freq data=have order=freq ;
weight profit ;
tables employee_id;
run;
... View more