BookmarkSubscribeRSS Feed
takahasm
Calcite | Level 5

Hello,

 

I want to know the top 3 most common reason for visit for each birth group for a dataset with 2 columns where:

  • Column 1 has birth group (so like child, senior, adult, etc) [BD_CLASS] 
  • Column 2 has that’s their reason for visiting the ER. [main_problem]

 

I tried using 

PROC SQL;
SELECT BD_CLASS, count(unique(main_problem)) as u_PROB
FROM work.test12
group by BD_Class;
quit;

but that only told me the number of unique problems in each birth group; not the most popular ones. 

 

Any help would be much appreciated

 

 

3 REPLIES 3
ballardw
Super User

Does this have to be done with SQL?

takahasm
Calcite | Level 5

no it doesn't! 

Reeza
Super User
1. Try ordering the data, so sort by U_PROB descending so that the top are on top.
2. Add OUTOBS=3 to limit to the top 3 but then you may lose any duplicates.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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