BookmarkSubscribeRSS Feed
KarlK
Fluorite | Level 6
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
2 REPLIES 2
Kevin_SAS
SAS Employee
This should do what you want.

proc print data=sashelp.class (obs=5)
style(header)=header2;
run;
KarlK
Fluorite | Level 6
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.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 798 views
  • 0 likes
  • 2 in conversation