I am trying to print subscript y axis label using annotation dataset as follows,
data anno;
length label $50;
ord=1; Function='TEXT'; label="Cmax (ng/mL)" ;
output;
ord=2; Function='TEXT'; label="AUC`{sub 24} (h*ng/mL)" ;
output;
ord=3; Function='TEXT'; label="AUC`{sub inf} (h*ng/mL)" ;
output;
ord=4; Function='TEXT'; label="AUC`{sub last} (h*ng/mL)" ;
output;
run;
data anno;
set anno;
x=5; y=50; width=40; xspace='graphpercent' ; yspace='graphpercent'; drawspace='graphpercent';/* anchor= "left" ;*/ id='par';
rotate=90 ; textsize=9 ; textweight="bold" ;
run;
but it print the on middle of the graph instead of graph area
The reason the label is printing in the middle is that the annotation variables for the X and Y positions are incorrectly named. These reserved variable names must be called X1 and Y1. Some annotations require two coordinates, in which case you would use X1/Y1 and X2/Y2. Let me know if you still have any issues.
data _anno;
length label $ 200;
drawspace="layoutpercent"; function="text"; textweight="normal"; textsize=12;textcolor="black"; width=200;
x1=50; y1=2.5;label="AUC(*ESC*){sub '24'}(h*ng/mL)"; output;
x1=2.5; y1=50;rotate=90;label="AUC(*ESC*){sub 'inf'}(h*ng/mL)"; output;
run;
proc sgplot data=sashelp.heart sganno=_anno noautolegend;
vbox weight/category=bp_status group=sex;
xaxis label=' ';
yaxis label=' ';
run;
hi Ksharp,
Thank you for your reply
Apparently it works in sgplot , but with sgrender its still printing in middle of graph instead of in Layout space. I am using following template
The reason the label is printing in the middle is that the annotation variables for the X and Y positions are incorrectly named. These reserved variable names must be called X1 and Y1. Some annotations require two coordinates, in which case you would use X1/Y1 and X2/Y2. Let me know if you still have any issues.
Hi Dan,
Yes, by changing to x1= & Y1= has fix the issue...Thank you for suggestion. One more question here please? I have tried different method by creating the macro variable contains the unicode for yaxis label and pass thought macro loop. But why the Unicode is not supported for letters a-z ?
The Unicode specification for subscripts does not support all a-z characters (see Unicode Superscripts and Subscripts). In addition, for most of those subscript characters in the specification, you will need to choose a "full-featured" Unicode font, i.e. a font that has most of the Unicode glyphs. Otherwise, the character will render as a box. A good sans-serif font to use is "Arial Unicode MS". Let me know if that works okay for you.
After I checked the DOC , and get right graph .
data anno;
length label $ 200;
id="BAR";
drawspace="graphpercent"; function="text"; textweight="normal"; textsize=12;textcolor="black"; width=200;
x1=50; y1=2.5;label="AUC(*ESC*){sub '24'}(h*ng/mL)"; output;
x1=2.5; y1=50;rotate=90;label="AUC(*ESC*){sub 'inf'}(h*ng/mL)"; output;
run;
proc template;
define statgraph anno;
begingraph;
entrytitle "Vehicle Statistics";
layout lattice / columns=2 columngutter=10 pad=(left=15);
layout overlay /
xaxisopts=(offsetmin=0.2 offsetmax=0.2)
yaxisopts=(display=none);
/* Draw the barchart of origin and MPG city */
barchart x=origin y=mpg_city / name="bar" stat=mean
group=type groupdisplay=cluster clusterwidth=0.7
dataskin=sheen;
annotate / id="BAR"; /* Draw the barchart label. */
endlayout;
layout overlay /
y2axisopts=(display=(ticks tickvalues));
/* Draw the histogram of MPG city */
histogram mpg_city / dataskin=sheen yaxis=y2;
densityplot mpg_city / yaxis=y2;
annotate / id="HIST"; /* Draw the histogram label. */
endlayout;
endlayout;
endgraph;
end;
run;
/* Render the graph with the annotation */
proc sgrender data=sashelp.cars template=anno sganno=anno;
where type in ("Sedan" "Sports" "SUV");
run;
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.