Help using Base SAS procedures

Largest by id and service

Accepted Solution Solved
Reply
Contributor
Posts: 69
Accepted Solution

Largest by id and service

I am not sure I am doing this correctly, but I have a very large dataset, 10 MILLION ROWS that I am trying to obtain the largest amount in the group. Here is an example of my data have and data need and the code, which I get an error:

DATA HAVE
IDSERVICENETPDAMT
1119000$10.00
1119001$5.00
1111010$15.00
1111049$50.00
2224000$2.00
2225000$5.00
2227000$15.00
2228001$10.00
DATA NEED
IDSERVICENETPDAMT
1111049$50.00
2227000$15.00

DATA NEED;

DATA HAVE;

large1=largest(1,of netpdamt);

by id service;

run;


Accepted Solutions
Solution
‎02-14-2014 04:34 PM
Super User
Posts: 19,768

Re: Largest by id and service

Functions in SAS work across rows, not down a column, so you'll need to use a Proc, such as means/summary or proc sql.

ie

proc means data=have noprint;

class id;

var netpdamt;

output out=want max(netpdamt)=largest;

ID service;

run;

View solution in original post


All Replies
Solution
‎02-14-2014 04:34 PM
Super User
Posts: 19,768

Re: Largest by id and service

Functions in SAS work across rows, not down a column, so you'll need to use a Proc, such as means/summary or proc sql.

ie

proc means data=have noprint;

class id;

var netpdamt;

output out=want max(netpdamt)=largest;

ID service;

run;

Super User
Posts: 11,338

Re: Largest by id and service

This might work.

proc summary data=have nway;

     class Id ;

     var netpdamt;

     output out=want (drop=_type_ _freq_) max= maxid(netpdamt(service))=ServiceMaxAmount;

run;

🔒 This topic is solved and locked.

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

Discussion stats
  • 2 replies
  • 156 views
  • 0 likes
  • 3 in conversation