【问题标题】:SAS- Condensing Multiple Rows, Keeping highest ValueSAS- 凝聚多行,保持最高价值
【发布时间】:2016-06-19 20:13:57
【问题描述】:

我正在尝试完成以下任务。我尝试过使用数组和排序,但似乎没有任何效果。任何帮助将不胜感激。

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

因此,基本上,为每个帐户保留最高分。

【问题讨论】:

    标签: sas multiple-columns


    【解决方案1】:

    只需使用PROC MEANS

    proc means data=have nway ;
      class acct ;
      var score1 score2 ;
      output out=want max= ;
    run;
    

    【讨论】:

    • 非常感谢!!,正是我想做的事
    【解决方案2】:

    我会推荐 PROC SQL:

    PROC SQL;
        CREATE TABLE want AS 
            SELECT Acct, 
                MAX(Score1) AS Score1, 
                MAX(Score2) AS Score2
            FROM have
                GROUP BY Acct;
    QUIT;
    

    【讨论】:

      猜你喜欢
      • 2022-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-06-09
      • 1970-01-01
      • 2019-05-27
      • 1970-01-01
      • 1970-01-01
      • 2014-06-28
      相关资源
      最近更新 更多