BookmarkSubscribeRSS Feed
ekomaroff
Calcite | Level 5

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. 

7 REPLIES 7
Ksharp
Super User
proc sgplot data=sashelp.heart;
histogram weight;
refline 250/axis=x label="(*ESC*){unicode alpha}=.05";
run;

Ksharp_0-1682336539343.png

 

ekomaroff
Calcite | Level 5
Yes, thank you. I knew how to add Unicode symbols to "Label" statements in general. Here, I want to get it working in "HREFLABEL" statement in the Histogram from Proc Univariate. I have a few good reasons for working with the Univariate histogram, instead of the SGPLOT histogram. If it is not possible, then I will simply put "alpha" in Roman letters but would prefer the Greek lowercase letter.
FreelanceReinh
Jade | Level 19

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
Calcite | Level 5
Brilliant, thank you! One more puzzle please. 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?
FreelanceReinh
Jade | Level 19

@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.

 

ekomaroff
Calcite | Level 5
I very much appreciate your effort, time and expert help. However, after I posted the question, I played around with more options (below) and the label moved to the right. Mysterious, but this is a one-off project so am very happy now. Working with you has made my day! Thanks again.

hreflabel='a = .05' infont='Symbol' LHREF=3 HREFLABPOS=1 chref = bio;

ballardw
Super User

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: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

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

View all other training opportunities.

Discussion stats
  • 7 replies
  • 795 views
  • 0 likes
  • 4 in conversation