data have;
input id age salary;
datalines;
1 23 3000
2 34 5000
4 26 2000
4 26 2000
5 32 4000
5 32 5000
;
proc sql;
select id,age,sum(salary) as salary
from have
group by id,age;
quit;
Or using my favorite proc:
proc means data=have nway noprint; class ID; id age; var salary; output out=want (drop=_:) sum=; run;
The id statement copies the age variable to the output dataset (assuming that it is constant within the variable ID).
The nway option hides the total row (all IDs).
The drop= dataset option drops the automatic variables _FREQ_ and _TYPE_.
Hope this helps,
Eric
Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.
Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.