使用 proc 报告在 RTF 输出中水平合并单元格
Merge cells horizontally in RTF output using proc report
我正在尝试在我的数据中的每个组上方创建一个摘要行。我有 2 个问题:
- 如何水平合并摘要行中的前 2 个单元格(下面红色的单元格)。
- 如何删除“性别”列中重复的 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;
我认为您不能在汇总行中合并单元格。
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;
我正在尝试在我的数据中的每个组上方创建一个摘要行。我有 2 个问题:
- 如何水平合并摘要行中的前 2 个单元格(下面红色的单元格)。
- 如何删除“性别”列中重复的 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;
我认为您不能在汇总行中合并单元格。
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;