- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Ex: text to be displayed in graph is ABx . I want to display x as subscript in proc sg plot waterfall model.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
You want to display this in the axis label or in a data label? ODS allows for Unicode characters, including super/subscripts.
/* Define sample data for the plot */
data sample;
do x=1 to 10;
y=int(ranuni(0)*100);
output;
end;
run;
/* Define the ODS escape character */
ods escapechar='^';
/* Define the attributes of the image file */
ods graphics / reset width=600px height=400px ;
title 'Using Subscripts and Superscripts';
proc sgplot data=sample;
scatter x=x y=y / markerattrs=(symbol=circlefilled color=blue);
/* Specify the 4-digit hex value for the subscript 2 and superscript 2 */
xaxis label="H^{unicode '2082'x}O^{unicode '00b2'x}";
/* Specify the 4-digit hex value for the superscript 2 and subscript 2 */
yaxis label="N^{unicode '00b2'x}H^{unicode '2082'x}";
run;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
A footnote in the graph, like an inset?
inset "Inset footnote for AB^{sub '2'} "
/ textattrs=(size=12pt) position=bottomleft;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Can you post your actual SGPLOT code? No need for data but just want to see how many places you're talking about needing a subscript (different places need different methods).
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Let me keep it simple.I have a text variable the values are A,B,C,D for A,B I wanna display superscript & subscript for C,D respectively.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
If you want to show super or subscripts in SGPLOT graph statements (TEXT, VBAR, etc.) then you need to find them in Unicode form (I think DAN found one for subscript x). They still don't support direct super or subscripts in SGPLOT unfortunately. If you can find the character you want though in Unicode form then you can use the following method to get the values into a graph statement:
Basically instead of having character values that include the escape character and Unicode value you need to make a formatted variable where the format contains the escape character and Unicode value. It's an extra step I feel should be removed at some point by SAS but for now that is how it works.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
We do currently support sup/sub in INSET statements in SGPLOT (as @ChrisHemedinger demonstrated); but, in other string situations (title, footnote, axis labels, legend labels, etc.), you must use a Unicode character to get sup/sub.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Here you go:
ods escapechar="~";
footnote f="Monotype Sans WT J" "This is an AB~{unicode '2093'x}";
proc sgplot data=sashelp.class;
scatter x=weight y=height;
run;
This key is choosing the correct font. The "2093' glyph is not available in every font -- only in the more "full-featured" fonts. If you are using san-serif fonts in your output, the font in the programs should work well for you.
Hope this helps!
Dan