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-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

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