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 want to have a -1 in superscript in the panel labels (= panelby variable) in SGPANEL (code below). I've tried it with a unicode from another forum post that i've used for the y-axis label (see code below) but it doesn't work. Does someone have a solution to my problem?

 

ods html5 style=analysis path="D:\Masterthesis\Statistik\2024\Grafiken"
          file="Unkraut-TM_25-4-24_Bhdlg.html";

ods graphics / width=4.5in;
ods escapechar='^';

title height = 1.5 "Mittlere Unkraut-Trockenmasse der Behandlungen";
footnote "Behandlungen innerhalb einer Düngerstufe mit gleichem Buchstabe nicht signifikant voneinander verschieden";


data Unkraut_TM_Bhdlg_N0_MT1;
    set Unkraut_TM_Bhdlg_N0_MT1;
    Low = Median - Standardfehler;
    High = Median + Standardfehler;
	LabelPos = High + 0.4;
run;


data Unkraut_TM_Bhdlg_N0_MT1;
    set Unkraut_TM_Bhdlg_N0_MT1;
    if NStufe = 0 then NStufe_Label = "0 (kg ha^{unicode '207B'x}^{unicode '00B9'x})";
    else if NStufe = 1 then NStufe_Label = "96 (kg ha^{unicode '207B'x}^{unicode '00B9'x})";
run;


proc sgpanel data=Unkraut_TM_Bhdlg_N0_MT1;
    panelby NStufe_Label / noheaderborder headerattrs=(size=11pt weight=bold) novarname; 
    vbarparm category=Behandlung response=Median / 
		group=Behandlung 
		groupdisplay=cluster;
    highlow x=Behandlung low=Low high=High / group=Behandlung 
		lineattrs=(color=black thickness=1 pattern=solid) 
		highcap=serif lowcap=serif;
	scatter x=Behandlung y=LabelPos / 
        datalabel=Buchstabe;
        datalabelattrs=(size=10pt weight=bold color=black)
		datalabelpos=center
        markerattrs=(size=0); 
    rowaxis label="Unkraut-TM (kg ha^{unicode '207B'x}^{unicode '00B9'x})" labelattrs=(size=11pt);
    colaxis display=none; 
run;

ods html5 close;
1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User

Here is DanH_sas 's code for this question.

proc format;
value $super(default=80) 
"F"="F (*ESC*){unicode '207B'x}(*ESC*){unicode '00B9'x}"
"M"="M (*ESC*){unicode '207B'x}(*ESC*){unicode '00B9'x}"
;
run;

proc sgpanel data=sashelp.class;
format sex $super.;
panelby sex / novarname headerattrs=(family="Arial Unicode MS" );
scatter x=weight y=height;
run;

Ksharp_0-1732256277749.png

 

View solution in original post

6 REPLIES 6
quickbluefish
Barite | Level 11

You might try using PROC TEMPLATE and PROC SGRENDER -- see a bunch of examples here:
https://www.lexjansen.com/sesug/2022/SESUG2022_Paper_227_Final_PDF.pdf

 

...but it's likely more trouble than it's worth.  I have tried to do something similar in SGPLOT -- trying to add superscripts to text specified in the TEXT statement, but I had no luck.  That said, I did not try the above template / sgrender combo.  

Ksharp
Super User

This question has been answered a couple of days before. Check this:

https://communities.sas.com/t5/Graphics-Programming/Superscript-in-yaxis-label-in-PROC-SGPLOT/m-p/95...

 

%let label1=weight  (*ESC*){sup 'mw -1'}  ;
%let label2=height  (*ESC*){sub 'mw -1'} ;


/*用于加X轴Y轴标签的上下标*/
data _anno;
length label $ 200;
 drawspace="layoutpercent"; function="text"; textweight="normal"; textsize=12;textcolor="black"; width=200;
 x1=55; y1=2.5;label="&label1."; output;
 x1=2.5;  y1=55;rotate=90;label="&label2."; output;
 run;
/*****画散点图*****/
proc sgpanel data=sashelp.class sganno=_anno;  
panelby sex; 
scatter x=weight y=height;   
rowaxis label=' ';
colaxis label=' ';
run;

Ksharp_0-1732240380774.png

 

DanH_sas
SAS Super FREQ

To do this for classification values in a variable (such as your panel variable), you will need to use a user-defined format. See the simple example below. Note that, in a user-defined format, you MUST use the default escape sequence (*ESC*) instead of a defined escapechar.

proc format;
value $super 
"F"="R(*ESC*){unicode '00b2'x}"
"M"="D(*ESC*){unicode '00b2'x}"
;
run;

proc sgpanel data=sashelp.class;
format sex $super.;
panelby sex / novarname;
scatter x=weight y=height;
run;
Abdus-Salaam
Obsidian | Level 7

Thank you really much for your help 🙂.

Ksharp
Super User

Here is DanH_sas 's code for this question.

proc format;
value $super(default=80) 
"F"="F (*ESC*){unicode '207B'x}(*ESC*){unicode '00B9'x}"
"M"="M (*ESC*){unicode '207B'x}(*ESC*){unicode '00B9'x}"
;
run;

proc sgpanel data=sashelp.class;
format sex $super.;
panelby sex / novarname headerattrs=(family="Arial Unicode MS" );
scatter x=weight y=height;
run;

Ksharp_0-1732256277749.png

 

Abdus-Salaam
Obsidian | Level 7

Thank you really much for your help 🙂.

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

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
  • 6 replies
  • 1290 views
  • 4 likes
  • 4 in conversation