I am trying to add a superscript in my title and this is what is happening. I am using SAS 9.4 - can anyone help identify the problem based on the image? Thank you.
ods escapechar='^';
proc sgplot data=datnoautolegend;
title "My Plot: Volume(ml^{sup 2})";
...
I think you need to use the super keyword like this
ods escapechar='^';
title "My Plot: Volume(ml^{super 2})";
proc print data=sashelp.class;
run;
@Melk , does that work for you?
Are you directing output to an external source or HTML?
When I run it, I see this
Hm, I am looking at it in my results viewer and exporting as rtf file, and still getting the same thing.
Version of SAS?
And show your code from the ODS RTF statement to the ODS RTF close.
My title in RTF shows
My Plot: Volume(ml2)
@Melk wrote:
I have SAS 9.4.
ods rtf file='temp.rtf';
proc sgplot data=dat noautolegend;
title "My Plot: (ml^{super 2})";
scatter x=new_method y=gs;
run;
quit;
ods rtf close;
Try adding NOGTITLE to the ODS RTF options. I think with the title out of the graph that RTF has a better chance of showing the text as desired. The default for RTF is GTITLE which leaves the title as part of the graph and the graph procedures have issues with escapechar stuff sometimes.
Try using the unicode value instead:
title "My Plot: Volume(ml^{unicode '00b2'x})";
That was my solution - which works in the pdf and rtf files. However the png graphics file only shows an empty rectangle where subscript 2 should be in the label for y-axis of an sgplot plot - a pity. How to fix?
data sganno;
length label $ 200;
drawspace="graphpercent"; function="text"; textweight="normal"; textsize=12;textcolor="black"; width=200;
/* x1=50; y1=2.5;label="&label1."; output;*/
x1=50; y1=95; label="Title -- My Plot: (ml(*ESC*){sup '2'})"; output;
x1=2.5; y1=50;rotate=90;label="My Plot: (ml(*ESC*){sup '2'})"; output;
run;
title;
ods graphics/reset=all;
proc sgplot data=sashelp.class noautolegend sganno=sganno pad=(top=1cm);
scatter x=weight y=height;
yaxis label=' ';
run;
quit;
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.