SAS-压缩多行,保持最高价值
SAS- Condensing Multiple Rows, Keeping highest Value
我正在努力完成以下任务。我尝试过使用数组和排序,但似乎没有任何帮助 work.Any 将不胜感激。
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
所以基本上,保持每个帐户的最高分。
只需使用PROC MEANS
。
proc means data=have nway ;
class acct ;
var score1 score2 ;
output out=want max= ;
run;
我会推荐 PROC SQL:
PROC SQL;
CREATE TABLE want AS
SELECT Acct,
MAX(Score1) AS Score1,
MAX(Score2) AS Score2
FROM have
GROUP BY Acct;
QUIT;
我正在努力完成以下任务。我尝试过使用数组和排序,但似乎没有任何帮助 work.Any 将不胜感激。
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
所以基本上,保持每个帐户的最高分。
只需使用PROC MEANS
。
proc means data=have nway ;
class acct ;
var score1 score2 ;
output out=want max= ;
run;
我会推荐 PROC SQL:
PROC SQL;
CREATE TABLE want AS
SELECT Acct,
MAX(Score1) AS Score1,
MAX(Score2) AS Score2
FROM have
GROUP BY Acct;
QUIT;