【问题标题】:Merge cells horizontally in RTF output using proc report使用 proc 报告在 RTF 输出中水平合并单元格
【发布时间】:2019-10-15 21:53:27
【问题描述】:

我正在尝试在我的数据中的每个组上方创建一个摘要行。我有两个问题:

  1. 如何在摘要行中水平合并前 2 个单元格(下面红色的单元格)。
  2. 如何删除 Sex 列中重复的 F 和 M(目前我可以通过仅将这些单元格的文本颜色更改为白色来解决此问题,但希望有更好的方法)

输出是一个 RTF 文件,我使用的是 SAS 9.4 - 桌面版。

这可以使用 proc 报告吗?

代码:

options missing=' ';
proc report data=sashelp.class nowd;
    columns sex name age weight;
    define sex / order;
    break before sex / summarize;
run;

【问题讨论】:

    标签: sas proc-report


    【解决方案1】:

    我认为您不能合并汇总行中的单元格。

    compute 块和 call define 的一些技巧可以改变单元格的值和外观。

    例如(对于较小的图像只需 J 名称):

    proc report data=sashelp.class nowd;
        where name =: 'J';
    
        columns sex name age weight;
    
        define sex / order;
        define age / sum;
        define weight / sum;
        break before sex / summarize style=[verticalalign=bottom];
    
        compute name;
          * the specification of / order for sex sets up conditions in the name value
          * that can be leveraged in the compute block;
    
          if name = ' ' then do; 
            * a blank name means the current row the compute is acting on 
            * is the summarization row;
    
            * uncomment if stat is not obvious or stated in title;
            * name = 'SUM';  
    
            * 'hide' border for appearance of merged cell;
            call define (1, 'style', 'style=[fontsize=18pt borderrightcolor=white]');
          end;
          else do;
            * a non-blank name means one of the detail rows is being processed;
            * blank out the value in the sex column of the detail rows;
            * the value assignment can only be applied to current column or those
            * to the left;
            sex = ' ';
          end;
        endcomp;
    
        compute after sex;
          * if you want more visual separation add a blank line;
          * line ' ';
        endcomp;
    run;
    

    【讨论】:

    • 谢谢!也很有用的解释
    猜你喜欢
    • 2022-01-03
    • 1970-01-01
    • 1970-01-01
    • 2015-07-31
    • 1970-01-01
    • 2010-12-26
    • 2023-03-23
    • 2012-01-12
    • 1970-01-01
    相关资源
    最近更新 更多