2014-10-10 129 views
0

我有以下的数据集(虚构数据):SAS PROC REPORT

data have; 
    input team $ goals_12 goals_13 var_12_13; 
cards; 
LIV 20 25 .25 
MNC 21 24 .14 
MUN 30 25 -.17 
ARS 10 12 .20 
CHE 23 23 0 
EVE 20 18 -.1 
TOT 10 0 -1 
; 
run; 

我试图创建此数据集的报告。以下是我有:

proc report data=have; 
    column team goals_12 goals_13 var_12_13; 
    define team/'Team'; 
    define goals_12/analysis '2012 Goals'; 
    define goals_13/analysis '2013 Goals'; 
    define var_12_13/order analysis format=percent. mean "Variance '12 to '13"; 
    rbreak after/summarize ul ol; 
run; 

这确实ALMOST我想要的一切。下面的事情我一直没能搞清楚:

  1. 名称摘要行“摘要”
  2. 排序按降序var_12_13使团队具有最高方差是第一
  3. 我需要方差列的汇总是总数的差异,而不是变化的平均值(所以它应该是-5%)

回答

1

试试这个:

proc sort data=work.have; by descending var_12_13; 

proc report data=have; 
    column team goals_12 goals_13 var_12_13; 
    define team/'Team'; 
    define goals_12/analysis '2012 Goals'; 
    define goals_13/analysis '2013 Goals'; 
    define var_12_13/order=data analysis format=percent. mean "Variance '12 to '13" weight=goals_13; 

    compute team; 
    if _BREAK_ in ('_RBREAK_') 
     then do; 
      team="Summary"; 
     end; 
    endcomp; 

    rbreak after/summarize ul ol; 
run; 
+0

这是非常接近。出于某种原因,对于团队TOT,-1不会转换为(100%)。另外,我可以格式化5%,这表明这是一个负数?现在看起来像是一个积极的变化。此外,我想使用proc排序,但认为有一个内部的方式来处理变量的proc报告。 – pyll 2014-10-10 14:49:19