BookmarkSubscribeRSS Feed
Obsidian | Level 7

Hi every one, I'm trying to change the font of histogram graph (axis label, ticks label,...) in proc univariate (from standard font to "Courier New" for example).

I just search and find out that in histogram statement, there are options with font like "font=options" and "infont=options"

I try all these options but nothing happens.

So how can I change the font in  proc univariate?

Many thanks in advance

Super User

"Nothing happens" is awful vague.

Are there errors in the log?: Post the code and log in a code box opened with the "</>"  icon to maintain formatting of error messages.

No output? Post any log in a code box.

Unexpected output? Provide input data in the form of data step code pasted into a code box, the actual results and the expected results. Instructions here: will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the "</>" icon or attached as text to show exactly what you have and that we can test code against.

Obsidian | Level 7

Sorry about my poor explanation,

"Nothing happens" is that even if I try to use "font=options", the standard font does not change

My code is something like that


ods graphics on /OUTPUTFMT=png;
ods select histogram;
Proc univariate data=WORK.MYEXCEL;
	Histogram AGEVAR / kernel normal font="Courier New" infont="Courier New"
		odstitle="Distribution of Age (in year) at Screening" ;
	inset n mean median stddev / pos=ne;

It can run without any warning or error but the font is still the standard one


Super User
FONT= option is for standard graphics - ie not ODS GRAPHICS.
It's under the section titled : Options for Traditional Graphics Output

Basically it's a historical option, you need to either modify the template or use SGPLOT instead to get around this easily
Obsidian | Level 7
Thanks a lot for this information
Barite | Level 11

Hi @James_Yu,


Can you use the SGPLOT procedure to create your histogram? Because it's fairly simple to change the font there. For example:


proc sgplot data=sashelp.heart;
title "Cholesterol Distribution";
histogram cholesterol;
density cholesterol;
density cholesterol / type=kernel;
keylegend / location=inside position=topright;
xaxis label = "Cholesterol" labelattrs=(size=12 weight=bold family="Courier New");

Otherwise if you want to use Proc Univariate, you will probably need to use a template to make the font change.

Obsidian | Level 7

Thanks for the idea

But I still need some statistics in the graph that the proc univariate could provide such as in inset statement (n mean median stddev) and Mu/Sigma in the label of the density curves

How can I display these statistics in the graph with proc SGPLOT ?

Thanks in advance.


Barite | Level 11
It is actually possible to calculate those values, and add them to the data step, and then display those values with the INSET statement in Proc SGPLOT.
You're welcome.
Barite | Level 11

@James_Yu , here is a style which has been modified. You can use this style template to obtain the Courier New font, and you can make some more modifications. It probably will take a bit of trial and error for you to understand how each part affects the plot: 


Before the Proc Univariate statement you will need to use ODS LISTING STYLE = STYLES.NEW_STYLE, and you should look at the outputted image file (as opposed to the file in SAS), because the changes will be there.


proc template;
 define style styles.new_style;
  parent = styles.default;
  style GraphFonts from  GraphFonts
      'NodeDetailFont' = ("<sans-serif>, <MTsans-serif>",7pt)
      'NodeLinkLabelFont' = ("<sans-serif>, <MTsans-serif>",9pt)
      'NodeInputLabelFont' = ("<sans-serif>, <MTsans-serif>",9pt)
      'NodeLabelFont' = ("Courier New",9pt)
      'NodeTitleFont' = ("<sans-serif>, <MTsans-serif>",9pt)
      'GraphDataFont' = ("<sans-serif>, <MTsans-serif>",7pt)
      'GraphUnicodeFont' = ("Courier New",9pt)
      'GraphValueFont' = ("Courier New",9pt)
      'GraphLabel2Font' = ("Courier New",15pt)
      'GraphLabelFont' = ("Courier New",15pt,bold)
      'GraphFootnoteFont' = ("<sans-serif>, <MTsans-serif>",10pt)
      'GraphTitleFont' = ("Courier New",11pt,bold)
      'GraphTitle1Font' = ("<sans-serif>, <MTsans-serif>",14pt, bold)
      'GraphAnnoFont' = ("<sans-serif>, <MTsans-serif>",10pt);
Obsidian | Level 7

Thanks a lot for the solution.

I will test this style template to see that if it could help me to achieve my goal



Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

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.

Get the $99 certification deal.jpg



Back in the Classroom!

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

View all other training opportunities.

Discussion stats
  • 9 replies
  • 4 in conversation