Howdy!
If I specify a font size in SGPLOT, SAS does not seem to actually produce that font size in ODS PDF. It seems to produce some larger font size. Here's example code.
ods pdf file = "M:\test.pdf";
ods graphics on / reset;
title1 height = 12pt font = 'Arial' 'Title 1';
title2 height = 11pt font = 'Arial' 'Title 2';
title3 height = 10pt font = 'Arial' bold 'Title 3';
footnote1 height = 9pt font = 'Arial' 'Footnote 1';
footnote3 height = 8pt font = 'Arial' 'Footnote 2';
proc sgplot data = sasHelp.class; series x = name y = age; xAxis valueAttrs = (family = 'Arial' size = 9.5pt); run;
proc sgplot data = sasHelp.class; series x = name y = age; xAxis valueAttrs = (family = 'Arial' size = 10pt); run;
proc sgplot data = sasHelp.class; series x = name y = age; xAxis valueAttrs = (family = 'Arial' size = 10.5pt); run;
proc sgplot data = sasHelp.class; series x = name y = age; xAxis valueAttrs = (family = 'Arial' size = 11pt); run;
proc sgplot data = sasHelp.class; series x = name y = age; xAxis valueAttrs = (family = 'Arial' size = 11.5pt); run;
proc sgplot data = sasHelp.class; series x = name y = age; xAxis valueAttrs = (family = 'Arial' size = 12pt); run;
ods pdf close;
Title1 comes out as 13 pt.
Title2 as 11.5 pt.
Title3 as 11 pt.
Footnote1 as 9.5 pt.
Footnote2 as 9 pt.
The x-axis tick values come out as 9.5, 11, 11, 11.5, 11.5, and 13 pt. respectively.
If I add noGTitle
and noGFootnote
to the ODS PDF statement, then the font sizes for the titles and footnotes are correct. It seems the problem is with the graphic procedure itself.
I checked the font sizes by copying the text from the PDF and pasting into Word. I am fairly certain the same happens with ODS RTF; I can't paste the text into Word, but eyeballing it, it looks the same. Attached are the PDF and RTF outputs each way, plus a screenshot of the side-by-side comparison of the two RTF files showing that the font without noGTitle definitely is bigger than the font with noGTitle.
Does anyone else also get this? I tested on a SAS session with no other options, custom configuations, etc. but maybe there's still something set on my machine that is messing it up.
Best regards,
Michael
Please describe the tool you are using to determine the font sizes. Not saying you are wrong but the limited tools I have for examining the created document show other values than you get though still not the specified. I copied formatted text for Title 1 and pasted into a Word document which let me see the font and size of 12.5 for example. And font for the X axis labels isn't Arial.
You may need the ODS GRAPHICS/ noscale ; option. Maybe. Supposedly the scaling only changes when you set different Width and/or Height options but since you are seeing some different results for title and footnote text it may be worth trying.
@ballardw wrote:
Please describe the tool you are using to determine the font sizes. Not saying you are wrong but the limited tools I have for examining the created document show other values than you get though still not the specified. I copied formatted text for Title 1 and pasted into a Word document which let me see the font and size of 12.5 for example. And font for the X axis labels isn't Arial.
You may need the ODS GRAPHICS/ noscale ; option. Maybe. Supposedly the scaling only changes when you set different Width and/or Height options but since you are seeing some different results for title and footnote text it may be worth trying.
I did the same as you. I copied the text from the PDF to Word which gave the font point sizes I mentioned. Interesting that you aren't getting the same ones! I also see that the labels for the axes (both X and Y) are not Arial but Albany AMT. (Although on my machine those two fonts look identical.)
@Jay54 wrote:
Try using ods graphics on / scale=off;
See last paragraph here:
https://documentation.sas.com/doc/en/vdmmlcdc/8.1/grstatproc/n0yadqm4wsfapgn1hzekfvu1ex0g.htm
Like you both suggest, I tried noScale. Same problem.
@Cynthia_sas wrote:
Hi, My understanding is that the Microsoft name for the Arial font is not the correct way to specify the font for the PDF location. When I need to specify Arial or an Arial-like font for a PDF file, I always use Arial Unicode MS or Albany AMT or Helvetica with PDF. For more information about Arial and PDF, read the article "The Scourge of Arial" https://www.marksimonson.com/notebook/view/the-scourge-of-arial .
Cynthia
At Cynthia's suggestion, I switched font faces. I changed to HelveticaNeueforSAS and to Albany AMT. The font face does change, but the same size problems persist. They are consistent at least, so 12pt upscales to 13pt with all three fonts: Arial, HelveticaNeueforSAS, and Albany AMT. I think we're narrowing the issue down to an SGPlot rendering issue. Perhaps there is some scaling happening despite the noScale option?
Try using
ods graphics on / scale=off;
See last paragraph here:
https://documentation.sas.com/doc/en/vdmmlcdc/8.1/grstatproc/n0yadqm4wsfapgn1hzekfvu1ex0g.htm
Just to make sure this is an "apples-to-apples" comparison, can you generate the output using the WORD destination and set the OUTPUTFMT on the ODS GRAPHICS statement to be SVG? The default DPI for PDF output is 150dpi, whereas WORD is using either 96 or 100dpi. That might be causing variation.
@DanH_sas wrote:
Just to make sure this is an "apples-to-apples" comparison, can you generate the output using the WORD destination and set the OUTPUTFMT on the ODS GRAPHICS statement to be SVG? The default DPI for PDF output is 150dpi, whereas WORD is using either 96 or 100dpi. That might be causing variation.
Hi Dan. I tried with the Word destination; however, I got the following warnings.
WARNING: The ODS WORD destination is preproduction in this release.
WARNING: Word destination does not support SVG images. Using the default
static format.
The same difference in font size occurs between gTitle and noGTitle. That's seen in [test side-by-side Word destination.docx]. Is there another outputFmt you would suggest to try rather than the default static format?
Edit: I tried EMF, and that seems to have fixed the issue. Now, the comparison looks more or less the same size, just with different smoothing. That's the [test side-by-side Word EMF.docx] attachment.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: