BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Gil_
Quartz | Level 8
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;

1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User

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

having amt=max(amt);
Run;

View solution in original post

2 REPLIES 2
Astounding
PROC Star

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".

Ksharp
Super User

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

having amt=max(amt);
Run;

sas-innovate-white.png

Missed SAS Innovate in Orlando?

Catch the best of SAS Innovate 2025 — anytime, anywhere. Stream powerful keynotes, real-world demos, and game-changing insights from the world’s leading data and AI minds.

 

Register now

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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