BookmarkSubscribeRSS Feed
deleted_user
Not applicable
Is it possible to format the column header row using proc template with ods html?

Here's some code that's NOT working (!) -- in the sense that it's not picking up the style Header in mystyle.

proc template;
define style styles.mystyle /store=sasuser.templat;
parent = styles.default;
style Header from Header /
foreground=yellow
background=red ;
end;
run;

ods html
file="&thepath.\test.xls"
stylesheet="&thepath.\test.css"
style=styles.mystyle;

proc print data=class noobs;
run;
ods html close;

Thanks!
1 REPLY 1
Cynthia_sas
SAS Super FREQ
Hi:
You could try one of the following destinations instead of ODS HTML:
1) ODS HTML3 (HTML 3.2 compliant tags)
2) ODS MSOFFICE2K (Microsoft-compliant HTML tags)
3) ODS TAGSETS.EXCELXP (Microsoft-compliant Spreadsheet Markup XML tags)

The fact is that Microsoft does not like to render HTML 4.01 tags, which is the type of HTML tag that ODS HTML creates by default. Microsoft had an issue with the W3C recommendation for HTML4 and so it created a Microsoft flavor of HTML.

The code below worked for me.

Also, I'm not sure why you're using STYLESHEET= with STYLE= unless you explicitly want an external CSS file to put on a web server. If you DO want a CSS file to put on the web server, then you should consider redoing your invocation. With your form of syntax (with &THEPATH) in the FILE= and STYLESHEET= options, the following LINK tag (incorrect) gets built:
[pre]
<link rel="stylesheet" href="c:\temp\test.css">
[/pre]
...which would be wrong because you should avoid physical file refs in an HREF attribute.

My suggested syntax results in the following LINK tags being built (relative HREFs):
[pre]
<link rel="stylesheet" href="test.css">
[/pre]

...which is a relative HREF and as long as you move the HTML file and the CSS file together, the LINK will not be broken.

cynthia
[pre]
ods path work.testtemp(update)
sasuser.templat(read)
sashelp.tmplmst(read);
ods listing close;

proc template;
define style styles.mystyle;
parent = styles.sasweb;
style Header from Header /
foreground=yellow
background=red ;
end;
run;

%let thepath = c:\temp;

ods html3 path= "&thepath" (url=none)
file="test_ht3.xls"
stylesheet="test_ht3.css"
style=styles.mystyle;

ods msoffice2k path= "&thepath" (url=none)
file="test_mso.xls"
stylesheet="test_mso.css"
style=styles.mystyle;

ods tagsets.excelxp path= "&thepath" (url=none)
file="test_xp.xls"
style=styles.mystyle;

proc print data=sashelp.class noobs;
run;
ods _all_ close;
[/pre]

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
  • 1 reply
  • 602 views
  • 0 likes
  • 2 in conversation