PROC报告RBREAK行可以包含多个级别的分组吗?

时间:2009-10-12 18:39:26

标签: sas

我有一些PROC REPORT代码生成一个包含2个分组级别的报告,但RBREAK总是只对所有内容进行总结。我得到这样的东西,例如:

    Row1: Type A  Before  100 200 300  
    Row2:         After   400 500 600   
    Row3: Type B  Before  100 200 300  
    Row4:         After   400 500 600  
    Row5: Total           700 800 900

有没有办法让PROC REPORT总结第二级分组完整?我有140,000多个观察值,现在我正在重复每个观察并将第一级分组变量设置为一个常量值,以获得包含第二级分组的制造总行:

    Row1: Type A  Before  100 200 300  
    Row2:         After   400 500 600   
    Row3: Type B  Before  100 200 300  
    Row4:         After   400 500 600  
    Row5: Total   Before  700 800 900
    Row6:         After   701 801 901

或者即使PROC REPORT无法自动执行任何操作,是否有更好的方法可以将总数放在最底层?我可以使用多标签格式......但就我所知,它们在PROC报告中不起作用。

1 个答案:

答案 0 :(得分:0)

使用proc tabulate非常容易:

/* test data */
data one;
  do type = "A", "B";
    do time = "Before", "After";
       drop AfterPremium;
       AfterPremium = 300 * (time="After");
       v1 = 100 + AfterPremium;
       v2 = 200 + AfterPremium;
       v3 = 300 + AfterPremium;
       output;
    end;
  end;
run;

proc tabulate data=one order=data formchar="|-+++++++++";
  class type time;
  var v1-v3;
  tables (type all="All Types")*time, (v1 v2 v3)*sum;
run;
/* on log
+----------------------+------------+------------+------------+
|                      |     v1     |     v2     |     v3     |
|                      +------------+------------+------------+
|                      |    Sum     |    Sum     |    Sum     |
+----------+-----------+------------+------------+------------+
|type      |time       |            |            |            |
+----------+-----------+            |            |            |
|A         |Before     |      100.00|      200.00|      300.00|
|          +-----------+------------+------------+------------+
|          |After      |      400.00|      500.00|      600.00|
+----------+-----------+------------+------------+------------+
|B         |Before     |      100.00|      200.00|      300.00|
|          +-----------+------------+------------+------------+
|          |After      |      400.00|      500.00|      600.00|
+----------+-----------+------------+------------+------------+
|All Types |Before     |      200.00|      400.00|      600.00|
|          +-----------+------------+------------+------------+
|          |After      |      800.00|     1000.00|     1200.00|
+----------+-----------+------------+------------+------------+
*/