【问题标题】:SAS how to color specific rows with ODS and proc reportSAS如何使用ODS和proc报告为特定行着色
【发布时间】:2021-04-25 12:52:04
【问题描述】:

我打算在一个表类中用特定条件(男性和名字以'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;

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

【问题讨论】:

    标签: sas ods


    【解决方案1】:

    由于您没有定义 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;
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多