Usage Note 23647: How can I color every other row in my ODS HTML output?
This FAQ provides two methods of coloring every other row of a table.
PROC REPORT
For procedures that don't have templates, you can use PROC REPORT and the CALL DEFINE statement, and
use _ROW_ as the variable to format. A counter is
created with a temporary variable so that you have a number on
each observation. Finally, use the MOD function to create
the condition.
data one;
input age sex $ height weight;
cards;
11 M 66 142
11 F 62 138
11 M 55 169
12 M 67 172
12 F 66 188
12 M 68 199
13 M 62 132
13 M 64 122
14 F 62 133
15 M 55 120
;
run;
ods html body='temp.html';
proc report data=one nowd;
column age sex height weight;
define age / order;
define sex / order;
define height / sum;
define weight / sum;
compute age;
count+1;
if mod(count,2) then do;
call define(_row_, "style", "style=[background=red]");
end;
endcomp;
run;
ods html close;
The DATA Step
For procedures that have templates, you can use the DATA step to highlight every other row.
The below example uses the CELLSTYLE statement with the MOD
function. The variable I controls the background
color of the odd rows, and the TEST statement binds the
data with the template.
data temp;
set sashelp.class ;
i=_n_;
run;
proc template;
define table x;
column i name age sex height weight;
define i; print=off; end;
cellstyle mod(i,2) as {background=pink };
use_name;
end;
ods html file="foo.htm";
test data=temp;
ods html close;
run;
See also the full PROC TEMPLATE FAQ and Concepts.
Operating System and Release Information
*
For software releases that are not yet generally available, the Fixed
Release is the software release in which the problem is planned to be
fixed.
| Type: | Usage Note |
| Priority: | low |
| Topic: | Third Party ==> Output ==> HTML SAS Reference ==> ODS (Output Delivery System)
|
| Date Modified: | 2004-07-06 12:27:07 |
| Date Created: | 2004-01-09 14:36:39 |