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-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

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
  • 1 reply
  • 313 views
  • 0 likes
  • 2 in conversation