Data visualization with SAS programming

labelattrs=GraphUnicodeText

Accepted Solution Solved
Reply
Respected Advisor
Posts: 3,768
Accepted Solution

labelattrs=GraphUnicodeText

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?


Accepted Solutions
Solution
‎11-30-2011 01:02 PM
SAS Super FREQ
Posts: 864

labelattrs=GraphUnicodeText

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


All Replies
Solution
‎11-30-2011 01:02 PM
SAS Super FREQ
Posts: 864

labelattrs=GraphUnicodeText

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

Respected Advisor
Posts: 3,768

labelattrs=GraphUnicodeText

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?

Esteemed Advisor
Posts: 6,883

labelattrs=GraphUnicodeText

SAS Super FREQ
Posts: 864

labelattrs=GraphUnicodeText

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

Respected Advisor
Posts: 3,768

Re: labelattrs=GraphUnicodeText

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.

SAS Super FREQ
Posts: 864

Re: labelattrs=GraphUnicodeText

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

Post a Question
Discussion Stats
  • 6 replies
  • 523 views
  • 0 likes
  • 3 in conversation