The SAS Output Delivery System and reporting techniques

2 Different Table Styles from a Single CSS Stylesheet: Possible?

Reply
Contributor
Posts: 65

2 Different Table Styles from a Single CSS Stylesheet: Possible?

I have a data-driven website, not generated in SAS, that displays various data tables on a single web page linked to a single CSS stylesheet. The different tables use different color schemes, depending on their content. This is accomplished using class attributes. So, the base table has, for example, black text in the header, and the corresponding style element is something like "th {color: #000000}". Another table type has red header text, with a style element like "th .header2 {color: #FF0000}. In the html for the table, the latter would appear as "text.

I'm now trying to do the same thing in SAS. I've changed all the class names in the stylesheet to be compatible with what SAS expects in ODS cssstyle= in 9.2, and it works for the base table type. What I can't get it to do is give me the alternate styling for the second table type. I tried something like:

proc print data=sashelp.class (obs=5)
style(header)=[class="Header2"];
run;

SAS produced html like:

Text

I was glad to see the "Header2" in the class element, but SAS followed it with the inline "style=..." which set all the attributes back to the base table header element. I confirmed that the "style=" was the problem by manually editing the html to remove that. Then the file displayed correctly in the browser with the Header2 style.

Is it possible to use a customized css stylesheet and use your own class attributes for some of the table elements? I can see a workaround where I use style= in proc print/report to over-ride the defaults, but the straight html way I'm doing now (not using SAS) seems so much more elegant.

Thanks in advance,
Karl
SAS Employee
Posts: 16

Re: 2 Different Table Styles from a Single CSS Stylesheet: Possible?

This should do what you want.

proc print data=sashelp.class (obs=5)
style(header)=header2;
run;
Contributor
Posts: 65

Re: 2 Different Table Styles from a Single CSS Stylesheet: Possible?

Duh. (Slaps forehead with palm.) I've done that many times with a style element I created in an ODS template. My brain was in HTML/CSS mode and I just didn't generalize.

Thanks, Kevin.
Ask a Question
Discussion stats
  • 2 replies
  • 150 views
  • 0 likes
  • 2 in conversation