SAS- Condensing Multiple Rows, Keeping highest Value

女生的网名这么多〃 提交于 2019-12-02 17:51:16

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!