BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
nickpatel
Calcite | Level 5

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

nickpatel_1-1707446259804.png

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
DanH_sas
SAS Super FREQ

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.

View solution in original post

8 REPLIES 8
Ksharp
Super User

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;

Ksharp_0-1707472066058.png

 

nickpatel
Calcite | Level 5

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 

 proc template;
      define statgraph lineplot;
            begingraph;
 
  layout lattice / columns=1 rows=1 columngutter=5;
 
  cell;
                 layout overlay /
                        yaxisopts=(offsetmin=0.02 offsetmax=0.02 
type=log display=(line ticks tickvalues  )
logopts=(base=10 tickintervalstyle=auto) 
tickvalueattrs=(size=7pt)
/*label=&ylbl. labelattrs=(size=9pt weight=bold)*/
                                                griddisplay=on gridattrs=(color=lightgray pattern=solid thickness=1pt)
                                                )
 
                        xaxisopts=(offsetmin=0.02 offsetmax=0.02
display=(line ticks tickvalues label) label="Dose (mg)" type=linear 
linearopts=(viewmin=&minval. tickvaluelist=(&xvalues) tickdisplaylist=(&xcvalues.) )
tickvalueattrs=(size=8pt)
labelattrs=(size=9pt weight=bold)
                        griddisplay=on gridattrs=(color=lightgray pattern=solid thickness=1pt) 
                                                /*minorgrid=true minorgridattrs=(color=lightgray pattern=solid thickness=0.5pt)*/)
;
 
seriesplot x=l10dose y=curve&i/ lineattrs=(thickness=1.3pt color=black);
seriesplot x=l10dose y=elower&i/ lineattrs=(thickness=1.3pt pattern=dash color=black);
seriesplot x=l10dose y=eupper&i/ lineattrs=(thickness=1.3pt pattern=dash color=black);
scatterplot x=l10dose y=aval&i / group=SUBJID groupdisplay=cluster
clusterwidth=0
                            markerattrs=(size=4pt color=black symbol=X) name='agtx' ;
annotate /id='par';
                                    drawtext textattrs=(color=black size=7pt) "A power model with 90% confidence interval is presented: Response = exp(&&intercept&i) x Dose^(&&slope&i); 90% CI (&&lcl&i, &&ucl&i)" / 
                                                width=100 widthunit=percent x=0 y=-1.5 anchor=bottomleft xspace=wallpercent yspace=graphpercent;
/* drawtext textattrs=(color=black size=9pt ) "&ylbl" / rotate=90*/
/*                                                width=40 widthunit=percent x=-5 y=25 anchor=center xspace=wallpercent yspace=graphpercent;*/
 
                  endlayout;
endcell;
  endlayout;
            endgraph;
      end;
run;
Ksharp
Super User

Sorry. I am not familiar with GTL.

Maybe @tc  @DanH_sas  could give you a hand.

DanH_sas
SAS Super FREQ

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.

nickpatel
Calcite | Level 5

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 ?

DanH_sas
SAS Super FREQ

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.

Ksharp
Super User

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;

Ksharp_0-1707791789428.png

 

nickpatel
Calcite | Level 5
HI Ksharp,
Yes indeed changing to X1= & Y1= , it would resolve the issue...

Thank you,
Nick

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 8 replies
  • 2434 views
  • 0 likes
  • 3 in conversation