Desktop productivity for business analysts and programmers

How to use MAX IF in SAS EG

Accepted Solution Solved
Reply
New Contributor
Posts: 3
Accepted Solution

How to use MAX IF in SAS EG

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

Accepted Solutions
Solution
‎04-03-2015 08:54 AM
Community Manager
Posts: 2,697

Re: How to use MAX IF in SAS EG

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

View solution in original post


All Replies
Solution
‎04-03-2015 08:54 AM
Community Manager
Posts: 2,697

Re: How to use MAX IF in SAS EG

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

New Contributor
Posts: 3

Re: How to use MAX IF in SAS EG

Hi Chirs,

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

ThanksSmiley Happy

☑ This topic is SOLVED.

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

Discussion stats
  • 2 replies
  • 304 views
  • 0 likes
  • 2 in conversation