Hi, I'm outputting a figure from proc sgplot to RTF with ODS. I need to get some subscripts in my y-axis titles since it's PK parameters. Here's an example of what I tried.
proc format;
value trtf
2='0.25 mg/kg'
3='0.75 mg/kg'
4='1.50 mg/kg'
5='3.0 mg/kg'
6='6.0 mg/kg'
7='12.0 mg/kg'
8='24.0 mg/kg'
9='48.0 mg/kg'
;
value paramf
1="AUC&esc.{sub 0-inf} (h*ng/mL)"
2="AUC&esc.{sub 0-24} (h*ng/mL)"
3="AUC&esc.{sub 0-t} (h*ng/mL)"
6="C&esc.{sub max} (ng/mL)"
14="T&esc.{sub max} (h)"
;
run;
&esc is a macro variable for escape character. This is the way I know to get subscript but it's not coming out right in output.
I have read on here that axis titles don't support sub and sup commands. I got 0 and - to subscript but I can't get the lowercase t.
came across that thread today as well but today I was just informed that I don't need to do the subscript.
/*
Here is an example
*/
/*用于加X轴Y轴标签的上下标*/
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 '0-inf'}"; output;
x1=2.5;y1=50;rotate=90;label="AUC(*ESC*){sup 'max'}"; output;
run;
/*****画散点图*****/
title ;
proc sgplot data=sashelp.class sganno=_anno;
scatter x=weight y=height;
xaxis label=' ';
yaxis label=' ';
run;
title;
Thanks. can try next week. I have to do different labels for each PK parameter though. Would I need a different _anno dataset then for each PK parameter?
I have to make different vertical box plots for each PK parameter. The labels should be what I posted in paramf. So the y-axis label needs to be whatever the respective PK parameter is.
You want this ?
data have;
set sashelp.heart;
if bp_status='High' then paramf=1;
if bp_status='Normal' then paramf=2;
if bp_status='Optimal' then paramf=3;
run;
data _anno;
length label $ 200;
x1space="datavalue"; y1space="layoutpercent";function="text";
textweight="normal"; textsize=12;textcolor="black"; width=200;
x1=1; y1=2.5;label="AUC(*ESC*){sub '0-inf'} (h*ng/mL)"; output;
x1=2;y1=2.5;label="AUC(*ESC*){sub '0-24'} (h*ng/mL)"; output;
x1=3;y1=2.5;label="AUC(*ESC*){sub '0-t'} (h*ng/mL)"; output;
run;
title ;
proc sgplot data=have sganno=_anno noautolegend;
vbox weight/category=paramf;
xaxis label=' ' display=(novalues);
yaxis label=' ';
run;
it is closer to what I am looking for but I need to use avalc as well. I am supposed to do vertical box plots of PK parameters by timepoint and ADA status (positive or negative). Each timepoint should be on a separate page. I'll take care of that with the by statement in sgplot. Y-axis label should be "PK Parameter (unit)".
I have to work off of a shell and there is no picture. I have already posted what was in the shell.
/*
Then it is hard to help you .
Ask your statistical who wrote this shell,what graph he want to look like.
You need know some sas programming to modify my code to suit your demand.
*/
data have;
set sashelp.heart(obs=1000);
if bp_status='High' then paramf=1;
if bp_status='Normal' then paramf=2;
if bp_status='Optimal' then paramf=3;
keep status paramf weight;
run;
proc sort data=have;by status;run;
data _anno;
length label $ 200;
x1space="datavalue"; y1space="layoutpercent";function="text";anchor="top";
textweight="normal"; textsize=12;textcolor="black"; width=22;
x1=1; y1=2;label="AUC(*ESC*){sub '0-inf'} (h*ng/mL)"; output;
x1=2;y1=2;label="AUC(*ESC*){sub '0-24'} (h*ng/mL)"; output;
x1=3;y1=2;label="AUC(*ESC*){sub '0-t'} (h*ng/mL)"; output;
run;
option nobyline;
title "Status is : #byval1";
proc sgplot data=have pad=(bottom=40) sganno=_anno noautolegend;
by status;
vbox weight/category=paramf nofill nooutliers nomean;
scatter x=paramf y=weight/jitter ;
xaxis label=' ' display=(novalues noticks);
yaxis label="PK Parameter (unit)";
run;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
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.