I am using proc sgpanel to create b&w graphics and output them to jpeg. They look good but journals have specific font requirements. How can to determine what font is being used with the Journal style? Is there an easy way make a global font change?
The default font you get for the JOURNAL style depends somewhat on the system you run (e.g. Windows, Linux, etc.) and the locale. Assuming an English (en_US) locale, You would get "Arial" if it is available (such as Windows). If it is not, you would get "Albany AMT". You can determine this mapping by looking at both the ODS systole and the SAS registry.
As for changing the fonts global, you could either change the font mapping in the registry (which I don't recommend), or create a small style that inherits from JOURNAL and just changes the fonts. In the GraphFonts style element, replace the font directives with the literal fonts you want. The first font in the list will be applied if found, otherwise the list will be walked until a font is found. Then, reference this new style from your ODS destination statement (e.g. ods html).
Hope this helps!
proc template;
define style styles.my_journal;
parent=styles.journal;
class GraphFonts /
"GraphAnnoFont" = ("<sans-serif>, <MTsans-serif>", 10pt)
'GraphDataFont' = ("<sans-serif>, <MTsans-serif>",7pt)
'GraphValueFont' = ("<sans-serif>, <MTsans-serif>",9pt)
"GraphUnicodeFont" = ("<MTsans-serif-unicode>", 9pt)
'GraphLabelFont' = ("<sans-serif>, <MTsans-serif>",10pt)
'GraphLabel2Font' = ("<sans-serif>, <MTsans-serif>",10pt)
'GraphFootnoteFont' = ("<sans-serif>, <MTsans-serif>",10pt)
'GraphTitle1Font' = ("<sans-serif>, <MTsans-serif>",14pt)
'GraphTitleFont' = ("<sans-serif>, <MTsans-serif>",11pt)
"NodeTitleFont" = ("<sans-serif>, <MTsans-serif>", 9pt)
"NodeLabelFont" = ("<sans-serif>, <MTsans-serif>", 9pt)
"NodeInputLabelFont" = ("<sans-serif>, <MTsans-serif>", 9pt)
"NodeDetailFont" = ("<sans-serif>, <MTsans-serif>", 7pt)
;
end;
run;
ods html style=my_journal;
/* code */
ods html close;
Thank you for the reply, but I am still too ignorant to make full use of it. I don't know what I am looking at in the registry, so I'll avoid doing anything there. What is ODS systole? It doesn't turn up on a Google search.
Finally, let's say I want the Journal style with Calibri font, is this the syntax for that?
proc template;
define style styles.my_journal;
parent=styles.journal;
class GraphFonts /
"GraphAnnoFont" = ("<sans-serif>, Calibri", 10pt)
"GraphAnnoFont" = ("<sans-serif>, Calibri", 10pt)
...... etc
That statement would have looked to the registry for the first font. If not found, THEN use Calibre. You'll want to replace all directives with literal fonts. In the case below, if Calibre is found, it will use it; otherwise, it will try to use Arial:
"GraphAnnoFont" = ("Calibri, Arial", 10pt)
@gp4 wrote:
This system of styles, templates, destinations is just about incomprehensible.
If you don't want to deal with a style you can provide overrides for almost any text. A brief example with defaults for the first graph and the second modifies the Colaxis values, the horizontal axis, by changing (likely) the font family and text size of the axis label and the tickmark values, plus for the label the the font style, italic, and weight, bold.
proc sgpanel data=sashelp.class; panelby sex /columns=2; scatter x=height y=weight/ group=age; run; proc sgpanel data=sashelp.class; panelby sex /columns=2; scatter x=height y=weight/ group=age; colaxis labelattrs=(Family=Arial Size=12pt Style=Italic Weight=Bold) valueattrs=(family=Serif size=6pt) ; run;
With some graphs, combining Title, Footnote, Bylines, horizontal and vertical axis, legend entries, reference lines, Hline or Vline curve labels, inset statement, text plot, axistables and I'm sure few other places that you can set text attributes it could be easy to miss one in a complex graph. Once you get a custom style set to use the same font(s) in the places needed it is much easier to reference the single style than to modify the text attributes manually. And STYLES are pretty independent of the ODS Destination.
If you want to make "camera ready for publication" charts you will spend a lot of time. Getting one style that is usable with Proc SGPLOT, SGPANEL, SGPIE, SGMAP and in all the likely needed place if you are going to submit to a specific publication often is worth the time. And if you want to submit the same graphs to a different publication with different text rules then modifying a style is going to be much easier than dealing with possibly 100's of option statements in multiple procedure calls.
Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.
Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.
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.