Data visualization with SAS programming

Changing fonts for sgpanel output

Reply
Occasional Contributor den
Occasional Contributor
Posts: 16

Changing fonts for sgpanel output

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;

SAS Super FREQ
Posts: 1,081

Changing fonts for sgpanel output

Use "Courier New"

Occasional Contributor den
Occasional Contributor
Posts: 16

Changing fonts for sgpanel output

Thanks for your reply.

I've tried using both Courier and Courier New previously and neither work.

SAS Super FREQ
Posts: 1,081

Changing fonts for sgpanel output

Seems to work for me.  I am using SAS 9.2 (TS2M3).  Here is the SGPLOT image.  Also works for SGPANEL.

Courier.png

SAS Super FREQ
Posts: 1,081

Changing fonts for sgpanel output

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;

Esteemed Advisor
Posts: 7,294

Changing fonts for sgpanel output

Does the following provide what you need?: http://support.sas.com/techsup/technote/ts659/ts659.html

Occasional Contributor den
Occasional Contributor
Posts: 16

Changing fonts for sgpanel output

Thanks for your reply.

I've had a look at the link you provided.  I've tried these methods previously but to no avail.

SAS Super FREQ
Posts: 890

Changing fonts for sgpanel output

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

Occasional Contributor den
Occasional Contributor
Posts: 16

Changing fonts for sgpanel output

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.

SAS Super FREQ
Posts: 890

Changing fonts for sgpanel output

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

Occasional Contributor den
Occasional Contributor
Posts: 16

Changing fonts for sgpanel output

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

Ask a Question
Discussion stats
  • 10 replies
  • 449 views
  • 0 likes
  • 4 in conversation