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


Only extract max height values  based on sex and iam tried below code
proc sql ;
select *, max(height) as height
from clss
group by sex ;
quit;

Data following:

data clss ;
input Name$ Sex$ Age Height Weight ;
cards ;
ghj F 14 50.5 75
HGG F 15 55 80
TYY M 14 52 75
OIU F 15 54 81
POI M 16 65 72
POJ M 15 62 87
KJN F 16 60 81
JHB M 14 61 75
HGV M 11 60 57
NHJ F 12 75 75
JHB M 13 70 55
HGS F 14 65 60
TRT M 13 60 55
QWA F 14 51 65
;

I need output like this
name sex age height weight
NHJ     F    12       75       75
JHB     M   13       70       55

1 ACCEPTED SOLUTION

Accepted Solutions
LinusH
Tourmaline | Level 20

If you wish to filter on an aggregation use the HAVING key word, like

Having height = max(height)

Data never sleeps

View solution in original post

1 REPLY 1
LinusH
Tourmaline | Level 20

If you wish to filter on an aggregation use the HAVING key word, like

Having height = max(height)

Data never sleeps

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 1 reply
  • 608 views
  • 0 likes
  • 2 in conversation