BookmarkSubscribeRSS Feed
Ken_oy
Fluorite | Level 6

Hi everyone.

Just a quick question. How can we use label statement in gplot to put special symbols in axis label?

For example, how to put a 'um' (mu m) there? I tried to copy that 'mu' symbol from "system map" (ms windows), but it just did not work.

Any suggestion? or any other method to do so? thanks.

20 REPLIES 20
Ken_oy
Fluorite | Level 6

I found a way to do this, by using the following code:

label=(f=arial h=3 c=black justify=c a=90 "Length (%sysfunc(byte(181),$1.)m)" )

The "%sysfunc(byte(181),$1.)" should show as the the 'mu' sign in the gplot. The number "181" came from the following unicode chart: (link)

Unicode Chart

We can see that "mu" can be located from "181" (Latin-1 Supplement chart). If we want other symbols, we can just simply replace the "181" with other numbers.

Then here comes the second question:

The method above works and only works for Latin-1 Supplement chart. How if we want to throw in other special symbols?

ballardw
Super User

Maybe go more old school and avoid the unicode by using one of the SAS GREEK fonts?

DanH_sas
SAS Super FREQ

For GPLOT, you can do it this way:

axis1 label=(font="Arial/unicode" "03bc"x "006d"x);

proc gplot data=sashelp.class;

plot weight*height / haxis=axis1;

run;

quit;

Assuming you have SAS 9.2 or greater, you can do this in SGPLOT using ODS escapement syntax:

proc sgplot data=sashelp.class;

xaxis label="(*ESC*){unicode mu}m";

scatter x=weight y=height;

run;

Hope this helps!

Dan

Ken_oy
Fluorite | Level 6

@DanH, Thanks for the quick reply. I tried you code, the code worked. The problem is, the "mu" and the "m" overlap each other. How can I set them one after another in the label? Thanks again!

Ken_oy
Fluorite | Level 6

What I tired was the GPLOT code, have not tried the Sgplot yet, but I will Smiley Happy

DanH_sas
SAS Super FREQ

Interesting...I don't see this overlap problem in my GPLOT output. What version of SAS do you have?

DanH_sas
SAS Super FREQ

I just ran the GPLOT example in 9.2 and 9.3, and the output in neither version showed the overlap. Could you have some settings active that could affect your graph rendering? Maybe start a fresh session and see if it still happens.

Ken_oy
Fluorite | Level 6

@DanH. I had the SAS 9.2, I tried to restart my SAS, but still keep having this "overlap" style label. I thought I might mess up the goption settings, but after doing a goption reset=all, I still got the following graph.

out1.png

DanH_sas
SAS Super FREQ

Ah, I was putting the label on the X axis instead of the Y axis, which would explain why I was not getting the overlap. Since you are running 9.2, and I know what type of plot you're generating, would this work for you?

proc sgplot data=sashelp.class;

yaxis label="This label contains a (*ESC*){unicode mu}m";

vbox height / category=age;

run;

Ken_oy
Fluorite | Level 6

, Yes your code worked in sgplot! thanks! The only reason that I did not use sgplot for my boxplot was that there is no "group" statement in SAS9.2. So still a SAS version problem, lol. But your code will be very useful for the future! thanks!!

GraphGuy
Meteorite | Level 14

Could you show the exact axis statement you're using when you see the overlap?

Is the axis label text horizontal, or angled?

One possible work-around is to insert some extra spaces between the two characters:

axis1 label=(font="albany amt" 'Here is a mu character:'

font="albany amt/unicode" '03bc'x font="albany amt" '  ' font="albany amt/unicode" '006d'x);

proc gplot data=sashelp.class;

plot height*weight / haxis=axis1;

run;

Ken_oy
Fluorite | Level 6

, Thanks for the advice. I tried your code but still had the sample overlap looking result.

In my Label statement, I used:

axis2 order= 0 to 800 by 100

      value=(f=arial c=black h=2.5)

      label=( h=3 c=black  a=90 font="Arial/unicode" "03bc"x font="albany amt" '  ' font="albany amt/unicode" '006d'x )

      minor=none;

I also tested DanH's code:

axis2 order= 0 to 800 by 100

      value=(f=arial c=black h=2.5)

      label=( h=3 c=black  a=90 font="Arial/unicode" "03bc"x "006d"x )

      minor=none;

GraphGuy
Meteorite | Level 14

Are you using Proc Boxplot, or Proc Gplot (or other)?

Which output are you using?  (dev=png, dev=actximg, dev=javaimg, other?)

Ken_oy
Fluorite | Level 6

no, I used gplot + %annotate to do those boxplots. Did not use any dev options.

I think it should be my SAS version problem.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

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
  • 20 replies
  • 4660 views
  • 4 likes
  • 4 in conversation