Hi,
How should we arrange our SAS code to select and retain the highest salary for each year (2003, 2004, 2005) for every individual (pnr
), while also capturing the corresponding company (CVR), start date, and education level for that highest salary? The goal is to output one row per person, with all relevant information attached to the highest salary for each year, ensuring no observations are lost or overwritten during the process.
In the attached file, I have made an example how we would like the Output.
Hope someone can help!
We don't have your data to test with, but here is a push in the right direction. PROC SUMMARY will compute the values you are asking for, and the MAXID option on the OUTPUT statement. Bare bones (untested, incomplete program)could look like this:
proc summary data=have nway;
var salary;
class pnr year;
output out=want max(sakary) = maxsal maxid.........;
run;
You'll need to read about maxid, and play with it to get the final program.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.
Ready to level-up your skills? Choose your own adventure.