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

Hi All,

I do not know how to use MAX IF function in SAS EG so that I can get the following output.

Given the left two columns, how can I get the output table (table only, not report) like below? Prefer using EG Query Builder, if cannot, code is also good for me. Thank you so much! Smiley Happy

SchoolScoreMax Score of the SchoolMin Score of the School
IT989870
Biz809980
Biz889980
Law979784
IT709870
Law849784
IT789870
Biz999980
Law869784
1 ACCEPTED SOLUTION

Accepted Solutions
ChrisHemedinger
Community Manager

The easiest point-and-click method is two queries: first to calc the Min/Max for each school group, then the second to join that result with the original detail.

In screen shots, with this data:

data scores;
infile datalines dsd delimiter=' ';
length school $ 3 score 8;
input school score;
datalines;
IT 98
Biz 80
Biz 88
Law 97
IT 70
Law 84
IT 78
Biz 99
Law 86
run;

STEP 1:

minmax.png

STEP 2:

join.png

The flow:

flow.png

Result:

result.png

Chris

It's time to register for SAS Innovate! Join your SAS user peers in Las Vegas on April 16-19 2024.

View solution in original post

2 REPLIES 2
ChrisHemedinger
Community Manager

The easiest point-and-click method is two queries: first to calc the Min/Max for each school group, then the second to join that result with the original detail.

In screen shots, with this data:

data scores;
infile datalines dsd delimiter=' ';
length school $ 3 score 8;
input school score;
datalines;
IT 98
Biz 80
Biz 88
Law 97
IT 70
Law 84
IT 78
Biz 99
Law 86
run;

STEP 1:

minmax.png

STEP 2:

join.png

The flow:

flow.png

Result:

result.png

Chris

It's time to register for SAS Innovate! Join your SAS user peers in Las Vegas on April 16-19 2024.
AmberLOL
Calcite | Level 5

Hi Chirs,

Thank you very much. I found that actually just the second step is enough. MAX(score) Group by school.

ThanksSmiley Happy

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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