DATA Step, Macro, Functions and more

getting max and min value by group

Accepted Solution Solved
Reply
Contributor
Posts: 25
Accepted Solution

getting max and min value by group

Hi all,

I am trying to get min and max value by group. Can anyone please help?

data max_min;

input group $ value;

datalines;

g1 30

g2 37

g2 76

g3 22

g3 84

g4 15

g4 21

g4 94

g4 73

;

run;

I want to get this output

group    value

g1         30

g2        76

g3        84

g4        94

Thank You!!


Accepted Solutions
Solution
‎08-21-2015 12:24 PM
Super User
Posts: 11,343

Re: getting max and min value by group

proc means data=max_min max min;

class group;

var value;

run;

This gets the max a min values as that is what your subject line said.

View solution in original post


All Replies
Solution
‎08-21-2015 12:24 PM
Super User
Posts: 11,343

Re: getting max and min value by group

proc means data=max_min max min;

class group;

var value;

run;

This gets the max a min values as that is what your subject line said.

Contributor
Posts: 25

Re: getting max and min value by group

This is the code I used

data max_min_new;

set max_min;

maxvalue= max(of value);

by group;

run;

Occasional Contributor
Posts: 17

Re: getting max and min value by group

proc sql;

     select group as group,

          max(value) as value

          from max_min

          group by group;

quit;


🔒 This topic is solved and locked.

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

Discussion stats
  • 3 replies
  • 14719 views
  • 0 likes
  • 3 in conversation