问题
I'm trying to accomplish the following. I have tried using arrays and sorting but nothing appears to work.Any help would be appreciated.
Acct Score1 Score2
9999 45 78
9999 58 65
8888 43 80
8888 43 90
8888 31 70
This is what I would like to end up with
Acct Score1 Score2
9999 58 78
8888 43 90
So basically, keep the highest score for each account.
回答1:
Just use PROC MEANS.
proc means data=have nway ;
class acct ;
var score1 score2 ;
output out=want max= ;
run;
回答2:
I would recommend PROC SQL:
PROC SQL;
CREATE TABLE want AS
SELECT Acct,
MAX(Score1) AS Score1,
MAX(Score2) AS Score2
FROM have
GROUP BY Acct;
QUIT;
来源:https://stackoverflow.com/questions/37911397/sas-condensing-multiple-rows-keeping-highest-value