Hi,
Running this code
filename EM email
to ="cxxx"
subject="Space Alert"
type ='text/html';
ods html3 file=EM;
proc odstext;
p "Hi all," / style=[fontsize=11pt fontfamily=Calibri];
run;
ods html3 close;
The generated HTML result is
<p align="LEFT"><font face="Calibri" size="3" color="#002288">Hi all,</font></p>
which Outlook displays as 12pt.
How can I get the correct size?
Hi:
Is there a reason that you're using ODS HTML3 for your example? I believe the default in ODS HTML3 was to translate your font size to a "relative" number that would then be displayed in the browser based on the relative size.
So taking email out of the picture and running just the PROC ODSTEXT to ODS HTML3, I also get the font changed to size 3.
However, switching to either "regular" ODS HTML or ODS HTML4 or ODS HTML5, I get the 11pt specified, as shown below:
ODS HTML4:
ODS HTML5:
Here's the code I ran:
ods html5(id=5) path='c:\temp' file='odstext_ht5.html' style=htmlblue;
ods html(id=4) path='c:\temp' file='odstext_ht4.html' style=htmlblue;
ods html3(id=3) path='c:\temp' file='odstext_ht3.html' style=htmlblue;
proc odstext;
p "Hi all," / style=[fontsize=11pt fontfamily=Calibri];
run;
ods html3(id=3) close;
ods html(id=4) close;
ods html5(id=5) close;
I took email out of the picture and used style=htmlblue for all 3 output files. I would recommend switching away from ODS HTML3 and/or do your file as a PDF or RTF attachment, because both of those destinations expect text to be specified in font sizes, while HTML doesn't always expect absolute font sizes.
Cynthia
Hi Cynthia,
Thank for your reply.
I use destination html3 in a effort to get slightly more usable results in Outlook as advised in https://support.sas.com/kb/21/133.html.
Other destinations lose all their formatting in Outlook. Destination MSOffice2K adds random boxes everywhere.
Also, SAS seems to have stabilised its style syntax to omit underscores for all keywords? fontsize= fontfamily= etc. Is that the case everywhere? That's a relief tbh.
Thanks, Chris
Thanks Cynthia.
Outlook switched from the IE renderer to the Word renderer 15 years ago, so it's disheartening that despite the plethora of html destinations, it is still unsupported even though it's the de facto corporate email tool.
Disappointing too that my font specification are simply ignored. I guess I need to write the HTML report by hand.
Thanks again for your always appreciated contribution! 🙂
Would there be a template style like
proc template;
define style style1;
style usertext / fontfamily="Calibri" fontsize=11pt ;
style cellcontents / fontfamily="Calibri" fontsize=11pt ;
for proc odstext text that would override size=3?
Hi:
I played around with a few PROC TEMPLATE solutions, but ODS HTML3 always created relative font sizes. I think that was part of how HTML3 worked with the original in-line styles. However, the ODS HTMLCSS destination also produced HTML3 output, but with CSS style specified. So when I tried your original code just with ODS HTMLCSS, then I did get the style override used, as shown below:
Of course, there is still Microsoft Outlook to contend with. I don't know whether Outlook will respect the HTMLCSS type of style specification. There's a chance that it will. But, as you can see in the DOCTYPE, ODS HTMLCSS does produce HTML 3.2 version of HTML output.
Cynthia
Thanks for this Cynthia.
I wasn't even aware of this version of the HTML output destination.
I gave it a go and sadly it's also badly received by Outlook .
proc odstext text is alright (though line spacing is altered), but ods text=, because it generates tables, is displayed surrounded by black lines.
It looks like the HTML has to be crafted manually.
Thanks again for your help!
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.
Ready to level-up your skills? Choose your own adventure.