Data visualization with SAS programming

special symbol in gplot labels

Reply
Frequent Contributor
Posts: 128

special symbol in gplot labels

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.

Frequent Contributor
Posts: 128

Re: special symbol in gplot labels

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?

Grand Advisor
Posts: 9,713

Re: special symbol in gplot labels

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

SAS Super FREQ
Posts: 864

Re: special symbol in gplot labels

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

Frequent Contributor
Posts: 128

Re: special symbol in gplot labels

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

Frequent Contributor
Posts: 128

Re: special symbol in gplot labels

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

SAS Super FREQ
Posts: 864

Re: special symbol in gplot labels

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

SAS Super FREQ
Posts: 864

Re: special symbol in gplot labels

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.

Frequent Contributor
Posts: 128

Re: special symbol in gplot labels

@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

SAS Super FREQ
Posts: 864

Re: special symbol in gplot labels

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;

Frequent Contributor
Posts: 128

Re: special symbol in gplot labels

, 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!!

SAS Employee
Posts: 963

Re: special symbol in gplot labels

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;

Frequent Contributor
Posts: 128

Re: special symbol in gplot labels

, 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;

SAS Employee
Posts: 963

Re: special symbol in gplot labels

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

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

Frequent Contributor
Posts: 128

Re: special symbol in gplot labels

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

I think it should be my SAS version problem.

Post a Question
Discussion Stats
  • 20 replies
  • 1636 views
  • 4 likes
  • 4 in conversation