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
"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: https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat... 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.
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;
Var AGEVAR;
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;
Run;
It can run without any warning or error but the font is still the standard one
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");
run;
Otherwise if you want to use Proc Univariate, you will probably need to use a template to make the font change.
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.
@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);
end;
run;
Thanks a lot for the solution.
I will test this style template to see that if it could help me to achieve my goal
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
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.