Hi:
It sort of depends on what procedure you want to do this with. Do you want to see alternating colors no matter WHAT procedure you use (alternating colors for PROC FREQ, PROC MEANS) or do you want to see alternating colors for a "List Data" task?
The challenge comes in because every DATA cell in a SAS output/report table is formatted with the CSS style for "DATA" (or the style template element "DATA") .... you CAN change your CSS file to have DATA1 and DATA2 style properties. But then the task becomes how to tell SAS to use DATA1 for the odd rows and DATA2 for the even rows. Just because the style properties are in the CSS file, doesn't mean that SAS will automatically use the style properties.
It is fairly easy to change row colors if you use PROC REPORT (instead of the LIST DATA task) to change the style of a _ROW_. For other procedures, you'd have to get into a change to the table template used for each color (because the other procedures are controlled by table templates). But for PROC REPORT you can make the change in a COMPUTE block:
[pre]
ods listing close;
** direct method;
** Create alternating colors by using a temporary;
** variable and a CALL DEFINE.;
ods html file='rep_altbar.html' style=sasweb;
proc report data=sashelp.class nowd
style(summary)={font_weight=bold};
title 'Highlight Every Other Row';
column name age height;
define name / order;
define age / display;
define height / display;
compute name;
tempvar + 1;
if mod(tempvar,2) = 0 then
call define(_ROW_,'STYLE','style={background=#ccccff}');
endcomp;
run;
ods html close;
ods listing;
title;
[/pre]
So the above method doesn't even use CSS...it just makes the change directly using the CALL DEFINE statement to change the background color of the alternating rows.
If you DID have a CSS file with DATA1 and DATA2, then you could do this with PROC REPORT:
[pre]ods html path='c:\temp'
file='usecss.html'
stylesheet=(url='
your_css_file.css');
proc report data=sashelp.class nowd;
column name age height;
define name / order;
define age /display;
define height/display;
compute name;
tmpvar + 1;
if mod(tmpvar,2) = 0 then call define(_ROW_,'STYLE',
'style={HTMLCLASS="Data1"}');
else if mod(tmpvar,2) ne 0 then call define(_ROW_,'STYLE',
'style={HTMLCLASS="Data2"}');
endcomp;
run;
ods html close;
[/pre]
Or, if you really wanted other procedures and not the equivalent of the LIST data task, in SAS 9.2, you could make a change to the "base" table template that every other table template (FREQ, MEANS, etc) would inherit from.
http://support.sas.com/rnd/base/new92/92odsmore.html#stripe
Until SAS 9.2, one other possible way to get alternating row colors is to use the TAGSETS.TABLEEDITOR destination, as described in this paper:
http://www2.sas.com/proceedings/forum2008/258-2008.pdf
(However, to make this destination work in EG, you'd have to download the template and then make sure that it was installed on the server machine, in a location that was going to be available every time you ran your jobs. You'd probably also need an ODS PATH statement added to your AUTOEXEC.SAS or EGAUTO.SAS files to make sure that the new template was always accessible.)
At any rate, you have possibilities. If you need help figuring this out in more detail, you might consider contacting Tech Support.
cynthia