BookmarkSubscribeRSS Feed
paulrockliffe
Obsidian | Level 7

Hello,

 

I have a table containing various Entities, each entity can have up to 5 reference numbers and each reference number can have an unlimited number of amounts associated with it.  So 3 columns, Entity, Reference, Amount

 

I want to extract a table that contains one result for each Entity and Reference combination and the largest Amount. 

 

I've done this before using the Sort task, but I can't get it to work where I'm grouping by more than one column in the Sort.

 

Does anyone have any top tips?

 

Thanks!

2 REPLIES 2
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Post example test data in the form of a datastep, and what the output from that should be.  I cant guess from that why:

proc sort data=have out=want nodupkey;
  by entity reference descending amount;
run;

Would not work.

Astounding
PROC Star

Here's a way:

 

proc summary data=have nway;

class entity refno;

var amount;

output out=want (keep=entity refno amount) max=;

run;

 

There are ways to do this where you run PROC SORT first, but you then need a DATA step to select the desired observations.

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