BookmarkSubscribeRSS Feed
SIgnificatif
Quartz | Level 8

Hi all,

I would like to perform a query to select top 3 ID's that have max row counts,

I have found that it's possible to do with this query :

proc sql;
create table want as
select *
from (select id, count(*) as cnt from have group by id_user)
having cnt=max(cnt);
quit;

 

but I would like to select top 3 ID' s that have the max count of rows of variable Name ( attached image) , the ID 1001 must come first , the 1002 second and 1004 third.

Anyone have an idea to that ?

countrow_order.jpg
Thanks.

3 REPLIES 3
PeterClemmensen
Tourmaline | Level 20

Why would ID=1004 and not 1005 be in the data? They both appear once?

SIgnificatif
Quartz | Level 8

yes,

we can add them,

the idea is to get top 3 , I don't need others, but ordering by variables count could also be an option.... so I can srroll trhough them all from top...

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

What is Bayesian Analysis?

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 3 replies
  • 1296 views
  • 0 likes
  • 3 in conversation