Help using Base SAS procedures

How to get max value off 3 coln

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 114
Accepted Solution

How to get max value off 3 coln

I have a dataset with 3 col I would need max here is example
Id. amt. Load. Date
23. 500. 100. 01/01/2018
23. 700. 100. 02/01/2018
23. 400. 100. 03/012018
30. 450. 20. 03/20/2018
30. 650. 20. 02/01/2018
30. 300. 20. 07/29/2018

What I need as output
Id. amt. Load. Date
23. 700. 100. 02/01/2018
30. 650. 20. 02/01/2018

This is the max of amt
I used
proc sql;
Create table report1 as
Select id as id,
Max(amt) as amt,
Load,
Max(date) as day
From report2
Group by dnd;
Run;


Accepted Solutions
Solution
‎04-15-2018 04:24 PM
Super User
Posts: 10,784

Re: How to get max value off 3 coln

proc sql;
Create table report1 as
Select *
From report2
Group by dnd

having amt=max(amt);
Run;

View solution in original post


All Replies
Super User
Posts: 6,781

Re: How to get max value off 3 coln

Here's a set of tools worth learning, so you are not forced to get SQL to do this:

 

proc sort data=have;

by id amt;

run;

data want;

set have;

by id;

if last.id;

run;

 

It doesn't matter if some of this is new to you.  These are tools you will use every week ... "must learn".

Solution
‎04-15-2018 04:24 PM
Super User
Posts: 10,784

Re: How to get max value off 3 coln

proc sql;
Create table report1 as
Select *
From report2
Group by dnd

having amt=max(amt);
Run;

☑ This topic is solved.

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

Discussion stats
  • 2 replies
  • 159 views
  • 2 likes
  • 3 in conversation