SAS 如何使用 ODS 和 proc 报告为特定行着色

SAS how to color specific rows with ODS and proc report

我计划在 table class:

中用特定条件(男性和名字以 'J' 开头)为某些行着色
ods excel close;
ods excel file='c://class.xlsx';
data class; set sashelp.class; 
  if substr(name,1,1)='J' and sex='M' then tt=1; 
run;
proc report data=class nowd;
 columns sex  height weight name age tt;
 compute tt;
  if tt=1 then call define(_row_, "style", "style=[backgroundcolor=yellow]");
 endcomp;
run;
ods _all_ close;

它不起作用,只是想知道如何解决它?

由于没有定义tt,默认使用的是分析柱。因此 ttcompute 中将不可用,而是 tt.<statistic>.

无论如何,添加一个 define 语句以指示 tt 用于显示并且条件样式将被正确应用。

proc report data=class ;
 columns sex  height weight name age tt;

 define tt / display;   /* explicitly specify column usage */

 compute tt;
  if tt=1 then call define(_row_, "style", "style=[backgroundcolor=yellow]");
 endcomp;
run;