使用标记集 excelXP 为分组 headers 的背景着色
Colorize background of grouped headers with tagsets excelXP
我正在尝试为 tagsets.ExcelXP 报告中的分组 headers 着色,我知道如何为未分组列的 headers 着色,但不知道如何更改分组的背景颜色。
这是我使用的示例代码:
data work.db;
infile datalines delimiter=';' dsd flowover;
input col01 col02 col03 col04 col05;
datalines4;
1;2;3;4;5
6;7;8;9;10
11;12;13;14;15
;;;;
run;
ods tagsets.ExcelXP file="c:\temp\example.xls";
proc report data=work.db nowd missing nocenter;
column
("group 1" col01 col02 col03 )
("group 2" col04 col05 )
;
define col01 / display style(header)={background=cxFFC000};
define col02 / display style(header)={background=cxFFC000};
define col03 / display style(header)={background=cxFFC000};
define col04 / display style(header)={background=cxC0FF00};
define col05 / display style(header)={background=cxC0FF00};
run;
ods tagsets.ExcelXP close;
当我运行这段代码时,我得到了这个结果:
Output of above code
这是我想要获得的:
Output that I'm trying to obtain
我如何修改我的代码来定义分组单元格“第 1 组”和“第 2 组”的背景颜色?
我尝试了“内联格式化”但没有得到结果(您可以在下面查看我修改后的代码)
ods escapechar = '^';
ods tagsets.ExcelXP file="c:\temp\example.xls";
proc report data=work.db nowd missing nocenter style={protectspecialchars=off};
column
("^{style[background=cxFF0000]}group 1" col01 col02 col03 )
("group 2" col04 col05 )
;
define col01 / display style(header)={background=cxFFC000};
define col02 / display style(header)={background=cxFFC000};
define col03 / display style(header)={background=cxFFC000};
define col04 / display style(header)={background=cxC0FF00};
define col05 / display style(header)={background=cxC0FF00};
run;
ods tagsets.ExcelXP close;
我肯定遗漏了什么,但我无法“看到”我遗漏了什么。
有人可以帮助我或给我建议吗?
提前致谢,
科斯坦蒂诺
所以,不幸的是,这有点复杂。
如果您有 至少一个 列不在分组之下,您可以使用文本变量来完成它 - 但这只有在至少有一个其他列的情况下才有效,因为对我来说并不完全有意义的原因。
例如:
data work.db;
infile datalines delimiter=';' dsd flowover;
id=_n_;
input col01 col02 col03 col04 col05 group1 $ group2 $;
datalines4;
1;2;3;4;5;group 1;group 2
6;7;8;9;10;group 1;group 2
11;12;13;14;15;group 1;group 2
;;;;
run;
ods tagsets.ExcelXP file="c:\temp\example.xls";
proc report data=work.db nowd missing nocenter;
column id
group1,(col01 col02 col03 )
group2,(col04 col05 )
;
define id/display;
define group1/' ' across noprint style(header)={background=orange};
define group2/' ' across noprint style(header)={background=lightblue};
define col01 / display style(header)={background=cxFFC000};
define col02 / display style(header)={background=cxFFC000};
define col03 / display style(header)={background=cxFFC000};
define col04 / display style(header)={background=cxC0FF00};
define col05 / display style(header)={background=cxC0FF00};
run;
ods tagsets.ExcelXP close;
' '
使实际的组变量标签不显示,而是显示变量内的文本,并且可以轻松设置样式。
如果您不,那么除了 DDE 或 SAS Office Add-in,我看到的唯一选择(DDE 不是一个很好的选择,因为它已被弃用而不是得到很好的支持,SAS Office add-in 是一个很好的选择,但它是一个单独的产品许可)可能正在使用 CSS 样式做一些复杂的事情......你可以识别 class 这些组所属做一个 first-child second-child 选择器。但这真的很复杂,而且基本上是手动的——如果有任何更改,您必须记住更改 CSS。类似于 Kevin Smith 在 Cascading Style Sheets: Breaking Out of the Box of ODS Styles 中的内容。
我正在尝试为 tagsets.ExcelXP 报告中的分组 headers 着色,我知道如何为未分组列的 headers 着色,但不知道如何更改分组的背景颜色。
这是我使用的示例代码:
data work.db;
infile datalines delimiter=';' dsd flowover;
input col01 col02 col03 col04 col05;
datalines4;
1;2;3;4;5
6;7;8;9;10
11;12;13;14;15
;;;;
run;
ods tagsets.ExcelXP file="c:\temp\example.xls";
proc report data=work.db nowd missing nocenter;
column
("group 1" col01 col02 col03 )
("group 2" col04 col05 )
;
define col01 / display style(header)={background=cxFFC000};
define col02 / display style(header)={background=cxFFC000};
define col03 / display style(header)={background=cxFFC000};
define col04 / display style(header)={background=cxC0FF00};
define col05 / display style(header)={background=cxC0FF00};
run;
ods tagsets.ExcelXP close;
当我运行这段代码时,我得到了这个结果: Output of above code
这是我想要获得的: Output that I'm trying to obtain
我如何修改我的代码来定义分组单元格“第 1 组”和“第 2 组”的背景颜色?
我尝试了“内联格式化”但没有得到结果(您可以在下面查看我修改后的代码)
ods escapechar = '^';
ods tagsets.ExcelXP file="c:\temp\example.xls";
proc report data=work.db nowd missing nocenter style={protectspecialchars=off};
column
("^{style[background=cxFF0000]}group 1" col01 col02 col03 )
("group 2" col04 col05 )
;
define col01 / display style(header)={background=cxFFC000};
define col02 / display style(header)={background=cxFFC000};
define col03 / display style(header)={background=cxFFC000};
define col04 / display style(header)={background=cxC0FF00};
define col05 / display style(header)={background=cxC0FF00};
run;
ods tagsets.ExcelXP close;
我肯定遗漏了什么,但我无法“看到”我遗漏了什么。
有人可以帮助我或给我建议吗?
提前致谢,
科斯坦蒂诺
所以,不幸的是,这有点复杂。
如果您有 至少一个 列不在分组之下,您可以使用文本变量来完成它 - 但这只有在至少有一个其他列的情况下才有效,因为对我来说并不完全有意义的原因。
例如:
data work.db;
infile datalines delimiter=';' dsd flowover;
id=_n_;
input col01 col02 col03 col04 col05 group1 $ group2 $;
datalines4;
1;2;3;4;5;group 1;group 2
6;7;8;9;10;group 1;group 2
11;12;13;14;15;group 1;group 2
;;;;
run;
ods tagsets.ExcelXP file="c:\temp\example.xls";
proc report data=work.db nowd missing nocenter;
column id
group1,(col01 col02 col03 )
group2,(col04 col05 )
;
define id/display;
define group1/' ' across noprint style(header)={background=orange};
define group2/' ' across noprint style(header)={background=lightblue};
define col01 / display style(header)={background=cxFFC000};
define col02 / display style(header)={background=cxFFC000};
define col03 / display style(header)={background=cxFFC000};
define col04 / display style(header)={background=cxC0FF00};
define col05 / display style(header)={background=cxC0FF00};
run;
ods tagsets.ExcelXP close;
' '
使实际的组变量标签不显示,而是显示变量内的文本,并且可以轻松设置样式。
如果您不,那么除了 DDE 或 SAS Office Add-in,我看到的唯一选择(DDE 不是一个很好的选择,因为它已被弃用而不是得到很好的支持,SAS Office add-in 是一个很好的选择,但它是一个单独的产品许可)可能正在使用 CSS 样式做一些复杂的事情......你可以识别 class 这些组所属做一个 first-child second-child 选择器。但这真的很复杂,而且基本上是手动的——如果有任何更改,您必须记住更改 CSS。类似于 Kevin Smith 在 Cascading Style Sheets: Breaking Out of the Box of ODS Styles 中的内容。