BookmarkSubscribeRSS Feed
nj_sas
Calcite | Level 5
I am trying to get line statement of font size of 14 or bigger and background of yellow or some color, in the compute before statement.

SAS 9.2, most recent XP tagset,

ods listing close;
ods tagsets.excelXP file='c:\temp\test.xls' style=sasweb;
ods escapechar='^';

proc report data=sashelp.class(obs=3) nowd;
column name age height weight sex;
compute before / style={just=l protectspecialchars=off};
text1 = "^{style[font_size=14pt color=blue background = yellow]
fontsize should be 14pt background color is yellow}";
line text1 $;
endcomp;
run;
ods _all_ close;

Thanks
1 REPLY 1
Cynthia_sas
Diamond | Level 26
Hi:
This issue has come up before
http://support.sas.com/forums/thread.jspa?messageID=50109쎽

And I modified your code sample below to illustrate the issue. Compare the HTML output (MSOFFICE2K) with the XML output (ExcelXP) -- you can see that the background change is honored by Excel when the HTML file is opened; and NOT honored by Excel when the XML file is opened.

You can do some changes in a style template -- but basically, some overrides are just not honored by Excel when you use TAGSETS.EXCELXP -- I believe it is a limitation of how styles are defined/used in the XML.

cynthia
[pre]
ods listing close;
title; footnote;
ods msoffice2k file='c:\temp\test1_mso.xls' style=sasweb;
ods tagsets.excelXP file='c:\temp\test1_xp.xls' style=sasweb
options(absolute_column_width="10");
ods escapechar='^';

proc report data=sashelp.class(obs=3) nowd
style(lines)={background=cyan font_size=18pt};
title '1) background will work in HTML (MSOFFICE2K) but not ExcelXP)';
column name age height weight sex;
compute before / style={just=l protectspecialchars=off background=yellow font_size=14pt};
text1 = "fontsize should be 14pt background color is yellow in HTML only";
line text1 $150.;
endcomp;
compute after;
text2 = 'This is a line with a cyan (default) background in HTML only';
line text2 $150.;
endcomp;
run;
ods _all_ close;

title; footnote;
** 2) Change the template NoteContent style element;
ods path work.tmp(update) sashelp.tmplmst(read);

proc template;
define style styles.linecolor;
parent=styles.journal;
class NoteContent /
foreground=black
background=pink
font_weight=bold
font_size=14pt;
end;
run;

ods msoffice2k file='c:\temp\test2_mso.xls' style=styles.linecolor;
ods tagsets.excelXP file='c:\temp\test2_xp.xls' style=styles.linecolor
options(absolute_column_width="10");
ods escapechar='^';

proc report data=sashelp.class(obs=3) nowd;
title '2) use a custom style template';
column name age height weight sex;
compute before / style={just=l protectspecialchars=off background=yellow font_size=14pt};
text1 = "fontsize should be 14pt background color yellow overrides style in HTML";
line text1 $150.;
endcomp;
compute after;
text2 = 'This is a line using the style template color';
line text2 $150.;
endcomp;
run;
ods _all_ close;
[/pre]

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 1154 views
  • 0 likes
  • 2 in conversation