BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Sean_OConnor
Obsidian | Level 7

Morning,

 

I've run a proc summary which has produced a count of values by different groups.

 

What I would like to do now is take this dataset and output the highest number obs for each group. The issue I'm having is trying to output the top obs per group when there are more than one highest in a group.

 

For instance there could be only 1 for one group but 3 for another. Any ideas how best to overcome this?

 

Thanks,

 

Sean

1 ACCEPTED SOLUTION

Accepted Solutions
sbxkoenk
SAS Super FREQ

4 ways to find the k smallest and largest data values in SAS
By Rick Wicklin on The DO Loop January 26, 2022
https://blogs.sas.com/content/iml/2022/01/26/k-smallest-largest-data.html

 

In CASL code ... you can use the action simple.topK, which selects the top K and bottom K values for variables in a data set, based on a user-specified ranking order.

 

Just don't forget to perform all your analyses by-group based !

 

Koen

View solution in original post

1 REPLY 1
sbxkoenk
SAS Super FREQ

4 ways to find the k smallest and largest data values in SAS
By Rick Wicklin on The DO Loop January 26, 2022
https://blogs.sas.com/content/iml/2022/01/26/k-smallest-largest-data.html

 

In CASL code ... you can use the action simple.topK, which selects the top K and bottom K values for variables in a data set, based on a user-specified ranking order.

 

Just don't forget to perform all your analyses by-group based !

 

Koen

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

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
  • 819 views
  • 0 likes
  • 2 in conversation