BookmarkSubscribeRSS Feed
Yury2
Calcite | Level 5

I need to create the subscript lower case letter n on the  SGPLOT axis. I read online how
to do this using Unicode but it does not work. It displays blank square
instead of a subscript. There is no error or warning messages in the
log. I used the dataset from the SASHELP library so that anyone can ran the code.  I am using SAS free server for academics. I am wondering  if the problem is with the server rather than with the code itself.  The code is below. Please, advise.

ods escapechar='~';
ODS GRAPHICS / ANTIALIASMAX=4100 ATTRPRIORITY=NONE ;
ODS PDF FILE="&reports.SGPLOT_with_subsript_n.pdf";

PROC SGPLOT DATA=SASHELP.CARS;
SCATTER X=LENGTH Y=Weight;
/* Use Unicode for subscript lowercase n */
YAXIS LABEL="W~{unicode '2099'x}"
labelattrs=(size=14pt family='Times New Roman Uni')
;
XAXIS LABEL="L~{unicode '2099'x}"
labelattrs=(size=14pt FAMILY="Times New Roman Uni")
;
RUN;

ODS PDF CLOSE;

 

4 REPLIES 4
Yury2
Calcite | Level 5

Thank you for suggestions. Unfortunately, it does not work. More specifically, the superscript 6 as in your example works but subscript n (Unicode 2099) does not. I am including the code.

 
 data _anno; 
length label $ 200; 
 drawspace="layoutpercent"; function="text"; textweight="normal"; textsize=12;textcolor="black"; width=200; 
 x1=50; y1=2.5;label="XXXXX(*ESC*){unicode '2099'x}"; output; 
 x1=2.5;  y1=50;rotate=90;label="YYYY(*ESC*){sub '6'}"; output; 
 run; 
 
proc sgplot data=sashelp.class sganno=_anno noautolegend ;    
scatter x=weight y=height/group=sex datalabel=name;    
xaxis label=' '; 
yaxis label=' '; 
run;
Ksharp
Super User
/*There is no need to use unicode character 
if you are using macro %sganno ,just type in it*/

 data _anno; 
length label $ 200; 
 drawspace="layoutpercent"; function="text"; textweight="normal"; textsize=12;textcolor="black"; width=200; 
 x1=50; y1=2.5;label="XXXXX(*ESC*){sub 'n'}"; output; 
 x1=2.5;  y1=50;rotate=90;label="YYYY(*ESC*){sub 'n'}"; output; 
 run; 
 
proc sgplot data=sashelp.class sganno=_anno noautolegend ;    
scatter x=weight y=height/group=sex datalabel=name;    
xaxis label=' '; 
yaxis label=' '; 
run;

Ksharp_0-1689680225265.png

 

Yury2
Calcite | Level 5

Thanks a lot. This worked!

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!

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
  • 419 views
  • 0 likes
  • 3 in conversation