hi guys,
i have a dataset something like:
company_name Employee_id ranking
ibm 100 4
ibm 100 6
ibm 101 5
apple 104 7
apple 104 8
........................
..........................
i need to pick the record of the empoyeer with the highest ranking :
ibm 100 6
ibm 101 5
apple 104 8
so was wondering if my logic is right:
proc sort data=have;by comp_name emp_id desecending ranking;
data want;
set have
by comp_name emp_id desecending ranking;
if first.emp_id?
Thanks
Fastest way is to try it. Best part about most programming is it's quick and easy to try things.
You should always have a method to test your logic, relying on a forum isn't a good way 🙂
Fastest way is to try it. Best part about most programming is it's quick and easy to try things.
You should always have a method to test your logic, relying on a forum isn't a good way 🙂
i did try it and for small dataset it worked but not sure if they were just a coincidence 🙂
That's why you build test cases.
Generate a basic case, then what happens if you have one one record per id, multiple records per id, multiple id's and finally, what if you have ties?
Submitting that code will return an error. Before testing your logic, you will need the correct syntax. Keyword desecending should be spelled descending.
Good luck.
so to confirm that logic works i created a temp flag =cats( comp_name, emp_id) and then sorted by tempflag ranking and applied "if first.tempflag" and got the same result as i got with the above approach so i guess i was on the right track
never had such situations so i was not sure 🙂
Cheers
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.
Early bird rate extended! Save $200 when you sign up by March 31.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.