BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
esita
Calcite | Level 5

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!!

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

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

3 REPLIES 3
ballardw
Super User

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.

esita
Calcite | Level 5

This is the code I used

data max_min_new;

set max_min;

maxvalue= max(of value);

by group;

run;

lxn1021
Obsidian | Level 7

proc sql;

     select group as group,

          max(value) as value

          from max_min

          group by group;

quit;


hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

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
  • 3 replies
  • 76151 views
  • 2 likes
  • 3 in conversation