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

发布于 2024-08-07 06:50:56 字数 796 浏览 1 评论 0原文

我有一些 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 REPORT 中不起作用。

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 wish I could use multi-label formats...but they don't work in PROC REPORT as far as I know.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

久伴你 2024-08-14 06:50:56

使用 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|
+----------+-----------+------------+------------+------------+
*/

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|
+----------+-----------+------------+------------+------------+
*/
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文