Help using Base SAS procedures

IDGROUP in proc summary

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 89
Accepted Solution

IDGROUP in proc summary

dear all,

code below gives the name of the oldest person per group.

but for F we have 2 with the same age!  HOW to get the equal values?

proc summary data=sashelp.class nway missing  ;

     class sex;

     output out=WORK(drop=_Smiley Happy      

          idgroup(max(age) out(age name)=mage name );

run;

proc print;

run;


i.e. we can get top 3 with this code, but that is not what i mean :smileyblush:

  proc summary data=sashelp.class nway missing  ; 

class sex; 

output out=WORK(drop=_Smiley Happy       

idgroup(max(age) out[3](age name)=mage name ); 

run; 

proc print; 

run;

GreetZ,

Herman


Accepted Solutions
Solution
‎07-19-2013 08:48 AM
Regular Contributor
Posts: 151

Re: IDGROUP in proc summary

The CLASS statement in Proc Summary (or Means) will only return one value per group.  To get what you want you can use sql.

proc sql;

select sex, age, name

from sashelp.class

group by sex

having age=max(age);

quit;

View solution in original post


All Replies
Solution
‎07-19-2013 08:48 AM
Regular Contributor
Posts: 151

Re: IDGROUP in proc summary

The CLASS statement in Proc Summary (or Means) will only return one value per group.  To get what you want you can use sql.

proc sql;

select sex, age, name

from sashelp.class

group by sex

having age=max(age);

quit;

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

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