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

Struggling to get a unicode symbol for micro into an SGPLOT axis.

 

This code works for the PROC PRINT, but the in the PROC SGPLOT (ODS HTML and ODS PDF) I get the unicode text:

 

data class;
  set sashelp.class;
  label height="Height (*ESC*){unicode 00B5}m";
run;

proc print data=class label;
run;

proc sgplot data=class;
  scatter x=height y=weight;
  **xaxis label="Height (*ESC*){unicode 00B5}m" labelattrs=GraphUnicodeText;
run;

So I tried hard-coding the label as a workaround, and added labelattrs=GraphUnicodeText, but then there was no symbol and no unicode text.

 

 

I thought with labelattrs I shouldn't have to worry about finding a font that supports a specific character?

 

Thanks.

BASUG is hosting free webinars Next up: Jane Eslinger presenting PROC REPORT and the ODS EXCEL destination on Mar 27 at noon ET. Register now at the Boston Area SAS Users Group event page: https://www.basug.org/events.
1 ACCEPTED SOLUTION

Accepted Solutions
Jay54
Meteorite | Level 14

proc sgplot data=sashelp.class;
scatter x=height y=weight;
xaxis label="Height (*ESC*){unicode '00B5'x}m" labelattrs=GraphUnicodeText;
run;

View solution in original post

4 REPLIES 4
Jay54
Meteorite | Level 14

proc sgplot data=sashelp.class;
scatter x=height y=weight;
xaxis label="Height (*ESC*){unicode '00B5'x}m" labelattrs=GraphUnicodeText;
run;

Quentin
Super User

Thanks @Jay54.  Is it necessary to provide the label on the x-axis statement?

 

Or should I be able to produce an axis label from a variable label with a unicode character?  I tried below, but doesn't work (I see the unicode text in the axis label rather than the micro symbol):

 

data class;
  set sashelp.class;
  label height="Height (*ESC*){unicode '00B5'x}m";
run;

proc sgplot data=class;
  scatter x=height y=weight; 
  xaxis labelattrs=GraphUnicodeText;
run;
BASUG is hosting free webinars Next up: Jane Eslinger presenting PROC REPORT and the ODS EXCEL destination on Mar 27 at noon ET. Register now at the Boston Area SAS Users Group event page: https://www.basug.org/events.
Jay54
Meteorite | Level 14

Unfortunately, the Unicode or other special characters in the data label itself will not get processed correctly.  The string will just be displayed as is in the label.  So, you have to use the axis LABEL option to set a unicode string.  Now, formats can include special Unicode values which will be used when formatting individual data values.

Tom
Super User Tom
Super User

You should be able to just put the UTF-8 string into the label.  At least it works when using utf8 session encoding .

 

proc sgplot data=sashelp.class;
  label height="Height" 'CEBC6D'x ;
scatter x=height y=weight;
xaxis labelattrs=GraphUnicodeText;
run;

Note that when you use multiple string literals in the LABEL statement then SAS will insert any spaces you have between the strings into the label.  Writing string literals right next to each other looks strange in the code so I included the ASCII code for lowercase m into the hexcodes rather than writing it like this.

  label height="Height "'CEBC'x'm' ;

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
  • 4 replies
  • 2924 views
  • 3 likes
  • 3 in conversation