Hi all,
I have created a panel plot using SGPANEL. I would like to change the fonts within the plot to Courier/Courier New. I have tried creating a new style using proc template (see code below) and ods graphics but with no luck. Any advice on how to change the fonts and save the output to a pdf file would be much appreciated.
proc template;
define style myfont;
parent=styles.default;
class GraphFonts /
'GraphDataFont' = ("Courier_New",10pt)
'GraphUnicodeFont' = ("Courier_New",10pt)
'GraphValueFont' = ("Courier_New",10pt)
'GraphLabelFont' = ("Courier_New",10pt)
'GraphFootnoteFont' = ("Courier_New",10pt)
'GraphTitleFont' = ("Courier_New",10pt)
'GraphAnnoFont' = ("Courier_New",10pt);
end;
run;
ods listing style=myfont;
ODS PDF FILE='C:\Projects\SummaryFigure.PDF';
ods graphics on;
Use "Courier New"
Thanks for your reply.
I've tried using both Courier and Courier New previously and neither work.
Seems to work for me. I am using SAS 9.2 (TS2M3). Here is the SGPLOT image. Also works for SGPANEL.
Here is the full program - SAS 9.2 (TS2M3):
proc template;
define style myfont;
parent=styles.listing;
class GraphFonts /
'GraphDataFont' = ("Courier New",10pt)
'GraphUnicodeFont' = ("Courier New",10pt)
'GraphValueFont' = ("Courier New",10pt)
'GraphLabelFont' = ("Courier New",10pt)
'GraphFootnoteFont' = ("Courier New",10pt)
'GraphTitleFont' = ("Courier New",10pt)
'GraphAnnoFont' = ("Courier New",10pt);
end;
run;
ods listing style=myfont;
ODS PDF FILE='C:\SummaryFigure.PDF' style=myfont;
ods graphics on / width=4in height=3in imagename='Courier';
title "Mileage by Type";
proc sgplot data=sashelp.cars;
vbar type / response=mpg_city stat=mean nostatlabel;
run;
ods pdf close;
ods graphics on / width=4in height=3in;
title "Mileage by Type";
proc sgpanel data=sashelp.cars;
panelby origin;
vbar type / response=mpg_city stat=mean nostatlabel;
run;
Does the following provide what you need?: http://support.sas.com/techsup/technote/ts659/ts659.html
Thanks for your reply.
I've had a look at the link you provided. I've tried these methods previously but to no avail.
I think the problem is that you've set your style on the LISTING destination, but you did not set it on the PDF destination. Styles must be set on each open destination, unless you want the default for that destination.
Hope this helps!
Dan
Thanks for your reply.
I've also tried specifying the style in the ods pdf statement previously, but this results in creating a grey background for my graphic and not altering the font at all.
You needed a combination of my answer and Sanjay's answer. You need to remove the underscore from "Courier_New" and make it "Courier New". I also suggest you use STYLES.LISTING instead of STYLES.DEFAULT so you will not get the gray background. Then, just set your new style on the PDf destination, and you should be all set.
Dan
I tried the combination of your and Sanjay's answers as you suggested and it worked well. Many thanks to both you and Sanjay for your advise.
Den
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
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.