Dear SAS community,
i'm trying to put a superscript -1 in my yaxis label in the following code:
ods escapechar='^'; proc sgplot data=Unkraut_TM_Bhdlg_N0_MT1 ; vbar Behandlung / response=Median stat=mean group=Behandlung groupdisplay=cluster; yaxis label="Unkraut-TM (kg ha^{super -1})"; run;
I've tried several versions of it:
yaxis label="Unkraut-TM (kg ha^{-1})";
yaxis label="Unkraut-TM (kg ha^{sup -1})";
yaxis label="Unkraut-TM (kg ha^{super -1})";
yaxis label="Unkraut-TM (kg ha(*ESC*){sup -1})";
yaxis label="Unkraut-TM (kg ha(*ESC*){super -1})";
yaxis label="Unkraut-TM (kg ha<sup>-1</sup>)";
yaxis label="Unkraut-TM (kg ha<sup>-1</sup>)";
yaxis label="Unkraut-TM (kg ha⁻¹)";
None of it did work.
Can someone help me with the simplest possible solution?
For an axis label, you have to use Unicode characters to do it. In your case, this would look like the following:
yaxis label="Unkraut-TM (kg ha^{unicode '207B'x}^{unicode '00B9'x})";
If for some reason the negative does not appear (you see a box instead), you might need to override the font via the LABELATTRS option to be a font like "Arial Unicode MS" that is a more "full-featured" Unicode font. Hope this helps!
For an axis label, you have to use Unicode characters to do it. In your case, this would look like the following:
yaxis label="Unkraut-TM (kg ha^{unicode '207B'x}^{unicode '00B9'x})";
If for some reason the negative does not appear (you see a box instead), you might need to override the font via the LABELATTRS option to be a font like "Arial Unicode MS" that is a more "full-featured" Unicode font. Hope this helps!
Thank you really much for the help, it worked.
Here is just once for all ,if you can't find a corresponding UNICODE code for superscript.
%let label1=体重(*ESC*){sup 'mw -1'} ;
%let label2=身高(*ESC*){sub 'mw -1'} ;
/*用于加X轴Y轴标签的上下标*/
data _anno;
length label $ 200;
drawspace="layoutpercent"; function="text"; textweight="normal"; textsize=12;textcolor="black"; width=200;
x1=50; y1=2.5;label="&label1."; output;
x1=2.5; y1=50;rotate=90;label="&label2."; output;
run;
/*****画散点图*****/
proc sgplot data=sashelp.class sganno=_anno;
scatter x=weight y=height;
xaxis label=' ';
yaxis label=' ';
run;
Thank you for the answer.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.
Ready to level-up your skills? Choose your own adventure.