BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Abdus-Salaam
Obsidian | Level 7

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?

 

1 ACCEPTED SOLUTION

Accepted Solutions
DanH_sas
SAS Super FREQ

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! 

View solution in original post

4 REPLIES 4
DanH_sas
SAS Super FREQ

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! 

Abdus-Salaam
Obsidian | Level 7

Thank you really much for the help, it worked.

Ksharp
Super User

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;

Ksharp_0-1731375317914.png

 

Abdus-Salaam
Obsidian | Level 7

Thank you for the answer.

SAS Innovate 2025: Register Now

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!

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 4 replies
  • 496 views
  • 5 likes
  • 3 in conversation