The SAS Output Delivery System and reporting techniques

ODS to Excel

Reply
N/A
Posts: 0

ODS to Excel

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!
SAS Super FREQ
Posts: 8,864

Re: ODS to Excel

Posted in reply to deleted_user
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]
Ask a Question
Discussion stats
  • 1 reply
  • 100 views
  • 0 likes
  • 2 in conversation