BookmarkSubscribeRSS Feed
BALI
Calcite | Level 5

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!

1 REPLY 1
Astounding
PROC Star

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.

SAS Innovate 2025: Register Now

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!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 294 views
  • 0 likes
  • 2 in conversation