BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
annapurna
Calcite | Level 5

Hi everyone

here is the data after  grouping my sample data by subject variable to find counts.

proc sql;

select subject,marks,count(*) as count

from marks

group by subject,marks;

quit;

subject      marks       count

maths        70            3

maths        85          10

maths        90            5

physics      55           3

physics      60           7

physics     80           2

English       75           9

English       85           5

i now want to create a table with  only those observations with max(count) from each subject,which should resemble like this

subject     marks    count

maths      85           10

physics    60           7

English    75           9

help me how to write a prog using proc sql to get this desired output (i dont want to use first. last. method from data step)

thanks in advance.

1 ACCEPTED SOLUTION

Accepted Solutions
stat_sas
Ammonite | Level 13

proc sql;

select * from marks

group by subject

having count=max(count);

quit;

View solution in original post

2 REPLIES 2
stat_sas
Ammonite | Level 13

proc sql;

select * from marks

group by subject

having count=max(count);

quit;

annapurna
Calcite | Level 5

thankyou stat@sas

its working

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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.

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
  • 2 replies
  • 1184 views
  • 1 like
  • 2 in conversation