BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
data_null__
Jade | Level 19

I want to use unicode characters for some of the characters in my Axis label(s).  If I specify

labelattrs=GraphUnicodeText

I can use a sequence in my label similar to this

(*ESC*){unicode '2081'x}(*ESC*){unicode '2080'x}

to produce in this case a "little" 10.

However this rest of the text uses a font that does no match the rest of my graph.  I used the default font for everything else.

I can change the FAMILY on the style attr but then the UNICODE does not work.

Is there a way to have UNICODE and the FONT too?

1 ACCEPTED SOLUTION

Accepted Solutions
DanH_sas
SAS Super FREQ

If you are using Arial (a fairly standard san-serif font) and you have "Arial Unicode MS" on your machine, you can use that font directly without a style reference. Doing that should give you the same font appearance in your graph. For example:

ods escapechar='~';

Title "Random Data from Two Study Groups";

proc sgplot data=random;

   xaxis type=log minor label="log~{unicode '2081'x}~{unicode '2080'x}x"

         labelattrs=(family="Arial Unicode MS");

   yaxis type=log minor label="log~{unicode '2081'x}~{unicode '2080'x}y"

         labelattrs=(family="Arial Unicode MS");

   scatter x=x y=y / group=g;

run;

Let me know if this works for you.

Thanks!
Dan

View solution in original post

6 REPLIES 6
DanH_sas
SAS Super FREQ

If you are using Arial (a fairly standard san-serif font) and you have "Arial Unicode MS" on your machine, you can use that font directly without a style reference. Doing that should give you the same font appearance in your graph. For example:

ods escapechar='~';

Title "Random Data from Two Study Groups";

proc sgplot data=random;

   xaxis type=log minor label="log~{unicode '2081'x}~{unicode '2080'x}x"

         labelattrs=(family="Arial Unicode MS");

   yaxis type=log minor label="log~{unicode '2081'x}~{unicode '2080'x}y"

         labelattrs=(family="Arial Unicode MS");

   scatter x=x y=y / group=g;

run;

Let me know if this works for you.

Thanks!
Dan

data_null__
Jade | Level 19

Hi Dan thanks a bunch I would never have used that name.  It works but AFAIK I do not have font with that name on my PC.  I do have Arial. 

The other complicating factor is the program is run on UNIX and I look at the RTF with word.

Can you tell me where in the documentation I can find this?

DanH_sas
SAS Super FREQ

If you are running SAS 9.2, the graph output you generate is an image. Since you're generating the graphs on Unix, you will need to use a Unix font. We ship fonts with SAS that can handle these Unicode characters, and we reference the appropriate font for the requested ODS style throught the GraphUnicodeText element. However, when the page is viewed in Word, the fonts on the PC are used for the page rendering. This brings us back to your original question.

If you are using the RTF style in ODS, the "Times Roman" font in the style (and used on the PC) should be very close to the "Thorndale Duospace WT J" referenced by GraphUnicodeText. Do you find that it is not the case?

Thanks!
Dan

data_null__
Jade | Level 19

Here is what I ended up using

labelattrs=GraphLabelText(family=GraphUnicodeText:FontFamily)

I appears to keep the default font and allow reconize (*ESC*){unicode ...} syntax.  That's all really wanted.

I think this was in Warren's book or maybe on someones blog.

I still don't understand the syntax and how it all works but I have lots of GTL to write so eventually I may get it.

Thanks for your help.

DanH_sas
SAS Super FREQ

Let me explain:

The GRAPHLABELTEXT you added to the LABELATTRS option is called an style "element" reference. This means that labelattrs picks up *all* of the style attributes in the GRAPHLABELTEXT element. When you add parenthesized attributes after this reference, you are overriding particular attributes from this element. In this case, you are overiding only the font family while leaving the other attributes intact. This is why your text is still at "label" size. Finally, the "GraphUnicodeText:FontFamily" is what we call a style "attribute" reference. You are referencing a particular attribute within a style element, in this case the font family from the GRAPHUNICODETEXT element.

This sum total is that you get label-style text using a true Unicode font 🙂

Hope this helps,

Dan

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 6 replies
  • 3847 views
  • 1 like
  • 3 in conversation