BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Ani7
Obsidian | Level 7

I'm trying to create about 50 scatterplots using proc sgplot with the following "template" code. However, when I output to PDF, none of the fonts appear in Times New Roman. Ideally, I want any text that appears to be in TNR. Is there something I need to change with the following code?

 

 

ods graphics on / noborder width=10in height=5in ANTIALIASMAX=4300;
options nodate nonumber orientation=landscape nobyline;
ods pdf file="&file." dpi=300;
title1 font="times new roman/bold" "&current_customer.";

proc sgplot data=customers (where=(customer = "&current_customer."));
	scatter x=invoice_date y=net_price / group=company filledoutlinedmarkers markerattrs=(symbol=circlefilled);
	yaxis max=7 min=0 label="Magnitude" labelattrs=(family="times new roman");
	xaxis display=(nolabel) interval=month min='01JAN2015'd max = '31DEC2022'd labelattrs=(family='times new roman')*/;
	keylegend / position=n title="" noborder valueattrs=(family="times new roman");
run;

My graph ends up looking like this (blocking out sensitive info

 

Ani7_0-1659583941258.png

Is there an option that I'm missing?

1 ACCEPTED SOLUTION

Accepted Solutions
Ani7
Obsidian | Level 7

Turns out it's in issue with which fonts are installed on the system. This link provides a way to find all fonts that are currently registered for use on SAS: https://documentation.sas.com/doc/en/pgmsascdc/v_006/uprint/n1nhqkljica33jn15t0phbocdl0x.htm

 

The solution was to change "Times New Roman" to "Times New Roman Uni"

View solution in original post

4 REPLIES 4
ballardw
Super User

I don't see and ODS PDF close statement. Are you sure you included one an ran it with the options? If by any chance you didn't then any previous version of the PDF was not replaced.

 

When I run this:

Ods pdf file="&outpath.\practice.pdf";

proc sgplot data=sashelp.class ;
   scatter x=height y=weight/group=sex datalabel
        datalabelattrs=(Family="Times New Roman")
  ;
  /* labelattrs affect the Axis Label ValueAttrs the tick mark text  
  */
  xaxis labelattrs=(Family="Times New Roman") valueattrs=(Family="Times New Roman") ;
  yaxis labelattrs=(Family="Times New Roman") valueattrs=(Family="Times New Roman") ;
  /* Titleattrs affect the Title of a legend, Valueattrs the text of the values */
  keylegend  /titleattrs=(Family="Times New Roman")  valueattrs=(Family="Times New Roman") ;

run;

ods pdf close;

the resulting PDF shows the graph elements in Times New Roman.  If your data is too sensitive then provide examples like this using a SAS data set instead. Then there are no questions about possible data issues.

 

You might also try using either "Times" or  "Serif" instead of "times new roman". Most of the SAS supplied styles will have a font family assigned to Serif and it is often a Times New Roman variant.

 

Ani7
Obsidian | Level 7

I ran the exact same code (and added a title) but my PDF still doesn't seem to contain Times New Roman. Is there something I'm doing wrong?

 


Ods pdf file = "&outfile./Test.pdf";

proc sgplot data=sashelp.class ;
   scatter x=height y=weight/group=sex datalabel
        datalabelattrs=(Family="Times New Roman") ;
		title "Class" font="Times New Roman";
  /* labelattrs affect the Axis Label ValueAttrs the tick mark text  
  */
  xaxis labelattrs=(Family="Times New Roman") valueattrs=(Family="Times New Roman") ;
  yaxis labelattrs=(Family="Times New Roman") valueattrs=(Family="Times New Roman") ;
  /* Titleattrs affect the Title of a legend, Valueattrs the text of the values */
  keylegend  /titleattrs=(Family="Times New Roman")  valueattrs=(Family="Times New Roman") ;

run;

ods pdf close;

Ani7_0-1659618298669.png

 

Ani7
Obsidian | Level 7

Turns out it's in issue with which fonts are installed on the system. This link provides a way to find all fonts that are currently registered for use on SAS: https://documentation.sas.com/doc/en/pgmsascdc/v_006/uprint/n1nhqkljica33jn15t0phbocdl0x.htm

 

The solution was to change "Times New Roman" to "Times New Roman Uni"

Ksharp
Super User

ballardw has already given  you the answer. But you could also try this one .

 

proc template;
define style styles.garamond;
parent=styles.listing; /* Or your favorite style */

style graphfonts from graphfonts / 
      'GraphDataFont' = ("Times New Roman, <MTsans-serif>",7pt)               
      'GraphUnicodeFont' = ("<MTsans-serif-unicode>",9pt)                  
      'GraphValueFont' = ("Times New Roman, <MTsans-serif>",9pt)              
      'GraphLabel2Font' = ("Times New Roman, <MTsans-serif>",10pt)            
      'GraphLabelFont' = ("Times New Roman, <MTsans-serif>",10pt)             
      'GraphFootnoteFont' = ("Times New Roman, <MTsans-serif>",10pt)          
      'GraphTitleFont' = ("Times New Roman, <MTsans-serif>",11pt,bold)        
      'GraphTitle1Font' = ("Times New Roman, <MTsans-serif>",14pt,bold)       
      'GraphAnnoFont' = ("Times New Roman, <MTsans-serif>",10pt);             
end;
run;

ods listing style=garamond;
ods pdf file="c:\temp\practice.pdf" style=garamond;

proc sgplot data=sashelp.class ;
   scatter x=height y=weight/group=sex datalabel ;
run;

ods pdf close;

 

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 2015 views
  • 0 likes
  • 3 in conversation