I created a Histogram with a reference line in Proc Univariate. Now I am trying to add the lower case Greek letter "alpha" to the reference line with the following command: hreflabel="^{unicode alpha}=.05"; However, the label is the text string " ^{unicode alpha}" with no number nor Greek letter. I tried other Unicode commands like 03B1 but same result. Thanks in advance for any help you can offer.
proc sgplot data=sashelp.heart;
histogram weight;
refline 250/axis=x label="(*ESC*){unicode alpha}=.05";
run;
Hello @ekomaroff,
Writing 'a' with the Symbol font results in 'a':
proc univariate data=sashelp.heart; var weight; histogram / href=250 hreflabel='a=.05' infont='Symbol'; run;
@ekomaroff wrote:
With your solution the label appears to the left of the reference line. Is there an option to get the label to the right of the reference line?
Using my (or rather Ksharp's) sashelp.heart example I get the label to the right of the reference line, which seems to be the default position. However, if I move the reference line far to the right (href=300), the label position switches to the left of the line, apparently because now there's not enough space on the other side. After creating sufficient space by adding an AXIS statement (to add one tick mark >300),
axis1 order=(70 to 310 by 10);
which I refer to in the HISTOGRAM statement options,
histogram / href=300 hreflabel='a=.05' haxis=axis1 infont='Symbol';
the label moves back to the right of the reference line.
In general I consider the analysis procs as exploratory when it comes to graphics. If I want a specific appearance then it usually much quicker to export the needed data from the procedure and use a dedicated procedure such as Sgplot or Sgpanel to create a desired appearance.
Most of the plots as part of analysis procedures have very few elements that you can control with options in the procedure and you can spend a lot of time playing with stuff and never get what you want.
Note that SGPLOT has a HISTOGRAM statement, so Univariate may not even be needed but might reduce the time "guessing" about likely bid widths or axis ranges.
The REFLINE statement in SGPLOT lets place labels inside or outside of the plot area, LABELLOC, and on the minimum or maximum value of the axis (left right when horizontal, top bottom when vertical) with LABELPOS. You also have more control over line and text appearance.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.