BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
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;

 

1 ACCEPTED SOLUTION

Accepted Solutions
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

 

View solution in original post

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!

sas-innovate-white.png

Special offer for SAS Communities members

Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.

 

View the full agenda.

Register now!

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 4 replies
  • 1039 views
  • 0 likes
  • 3 in conversation