Using an annotation data set might work. In the program below, I used the SASHELP.CLASS data set.
ods rtf
file='/folders/myfolders/ODS Graphics/subscripts_and_superscripts_via_annotations_PROC_SGPLOT.rtf'
style=HTMLBlue;
ods pdf file='/folders/myfolders/ODS Graphics/subscripts_and_superscripts_via_annotations_PROC_SGPLOT.pdf';
ods escapechar="^";
ods graphics on / attrpriority=none noborder;
* you can use data step coding to set up the annotations, but it can get complicated
* quickly. ;
data anno;
infile datalines dlm='#';
length function $ 8 label $ 50 drawspace $ 12 textweight $ 4 justify $ 6;
input function $ drawspace $ rotate width textweight $ justify $ x1 y1 discreteoffset label $;
datalines;
text # graphpercent # 90 # 50 # bold # center # 2 # 50 # -0.5 # SR^{sub 'P'} (2 Chamber) (s^{sup '-1'})
text # graphpercent # 0 # 50 # bold # center # 50 # 98 # -0.5 # SR^{sub 'P'} (2 Chamber) Trend by Surgical Method
;
run;
* used the pad option on PROC SGPLOT to create room for the annotations.
* otherwise, they may end up jammed too close to the plot. ;
proc sgplot data=sashelp.class pad=(left=20 top=20) sganno=anno;
scatter x=weight y=height;
yaxis display=(nolabel);
run;
* SAS provides a bunch of macros to do annotation, which is the easier way! ;
%sganno;
%let yaxislabel=SR(*ESC*){sub 'P'} (2 Chamber) (s(*ESC*){sup '-1'});
%let titlelabel=SR^{sub 'P'} (2 Chamber) Trend by Surgical Method;
data anno_via_macros;
%sgtext(drawspace="wallpercent", x1=-20, y1=40, width=70, rotate=0,
textweight="bold", justify="center",
label="&yaxislabel");
%sgtext(drawspace="wallpercent", x1=50, y1=105, width=70, rotate=0,
textweight="bold", justify="center",
label="&titlelabel");
run;
proc sgplot data=sashelp.class pad=(left=30pct top=10pct) sganno=anno_via_macros;
scatter x=weight y=height;
yaxis display=(nolabel);
run;
ods rtf close;
ods pdf close;
The y axis label text looks fine in the Results Viewer, but when I opened the RTF, the term involving the negative exponent was jumbled. When I opened the PDF, there was a gap between the s and the negative exponent.
I tried adding some extra space to the left side of the graphic, so that the annotation for the y axis would fit if I didn't rotate it. The term involving the negative exponent looks as expected in the RTF output.
I found Dan Heath's paper Annotating the ODS Graphics Way! helpful in figuring this out.
... View more