BookmarkSubscribeRSS Feed
tarheel13
Rhodochrosite | Level 12

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. 

 

13 REPLIES 13
svh
Lapis Lazuli | Level 10 svh
Lapis Lazuli | Level 10
Have you tried it with the actual escape character to see if the macro facility is not resolving the macro variable? I have only used unicode characters in formats with the format statement in open code like this: (*ESC*){unicode '2013'x}
tarheel13
Rhodochrosite | Level 12

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.

svh
Lapis Lazuli | Level 10 svh
Lapis Lazuli | Level 10
This thread suggests it can work if you find the right unicode text.

https://communities.sas.com/t5/Graphics-Programming/Superscript-in-axis-label-SGPLOT/td-p/529656
tarheel13
Rhodochrosite | Level 12

came across that thread today as well but today I was just informed that I don't need to do the subscript.

Ksharp
Super User
/*
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;

Ksharp_0-1668772234094.png

 

tarheel13
Rhodochrosite | Level 12

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? 

Ksharp
Super User
I don't understand what you mean.
Post a picture to explain .
tarheel13
Rhodochrosite | Level 12

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.

Ksharp
Super User

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;

Ksharp_0-1668932692756.png

 

tarheel13
Rhodochrosite | Level 12

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)". 

Ksharp
Super User
Post your real data and a picture you want to see.
It is hard to understand what you want by your words.
tarheel13
Rhodochrosite | Level 12

I have to work off of a shell and there is no picture. I have already posted what was in the shell. 

Ksharp
Super User
/*
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;

Ksharp_0-1669083453049.png

Ksharp_1-1669083465128.png

 

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 13 replies
  • 1784 views
  • 2 likes
  • 3 in conversation