tags:

views:

253

answers:

1

I have some PROC REPORT code that generates a report with 2 levels of grouping, but the RBREAK always just summarizes for everything. I get something like this for example:

    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

Is there any way to get PROC REPORT to summarize with that second level grouping intact? I have 140,000+ observations, and right now I'm duplicating every observation and setting the first level grouping variable to one constant value to get a manufactured total row with the second level grouping included:

    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

Or even if PROC REPORT can't do anything automatically, is there a better way to get the total at the bottom? I with I could use multi-label formats...but they don't work in PROC REPORT as far as I know.

A: 

This is really easy to do with 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|
+----------+-----------+------------+------------+------------+
*/
Chang Chung
Thanks for the example Chang, but I'm using things like computed columns and such in my PROC REPORT, and I'm using styles for HTML output (which to me seem easier and better supported in PROC REPORT). Are similar things available in PROC TABULATE? Thanks for all your help...again!
chucknelson
@chucknelson. computed columns are not available in proc tabulate.
Chang Chung