- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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" "¤t_customer.";
proc sgplot data=customers (where=(customer = "¤t_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
Is there an option that I'm missing?
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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"
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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"
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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;