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;
/*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;
See this example from @Ksharp
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;
/*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;
Thanks a lot. This worked!
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.
Ready to level-up your skills? Choose your own adventure.