BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
DGrint
Obsidian | Level 7

I'm using SGPLOT to create a KM plot and the xaxistable statement to add a number a risk table under the graph. When I give the xaxistable a title it is positioned above the second column in the table, not above the first column containing the row names. How can I get the title to appear above the first column?

 

Thanks

xaxistable atrisk1 / x=risk_time1 location=outside position=bottom class=e04brand 
						title="N at Risk" 
						titleattrs=GraphUnicodeText nomissingclass;
1 ACCEPTED SOLUTION

Accepted Solutions
WarrenKuhfeld
Rhodochrosite | Level 12

Here is an example of using PROC LIFETEST using techniques fromhttp://support.sas.com/documentation/onlinedoc/stat/142/kaplan.pdf .  I also show an SG annotation example, but outside the context of a KM plot.

data _null_;
   %let url = //support.sas.com/documentation/onlinedoc/stat;
   infile "http:&url/ex_code/143/templft.html" device=url;
   file 'macros.tmp';
   input;
   _infile_ = tranwrd(_infile_, '&', '&');
   _infile_ = tranwrd(_infile_, '&lt;' , '<');
   if index(_infile_, '</pre>') then pre = 0;
   if pre then put _infile_;
   if index(_infile_, '<pre>')   then pre + 1;
run;

%inc 'macros.tmp' / nosource;

%ProvideSurvivalMacros

%macro StmtsBeginGraph; 
  * Coordinates are ad hoc, and there are many 
     available coordinate systems.
     See the documentation for more information.;
  drawtext textattrs=(weight=Bold) 'CD4<100 cells/(*ESC*){unicode mu}L' / 
                  x=8 y=14 width=20;
%mend;

%CompileSurvivalTemplates

ods html body='b.html';
ods graphics on;
proc lifetest data=sashelp.BMT 
                      plots=survival(atrisk outside maxlen=13);
   time T * Status(0);
   strata Group;
run;

data anno;
   label = 'CD4<100 cells/(*ESC*){unicode mu}L';
   function = 'text';
   drawspace = 'GraphPercent';
   x1 = 15;
   y1 = 5;
   width = 25;
run;

proc sgplot data=sashelp.class sganno=anno;
   scatter y=weight x=height;
run;

ods html close;

View solution in original post

5 REPLIES 5
RW9
Diamond | Level 26 RW9
Diamond | Level 26

I have nothing to test this on, but I am guessing something in:

GraphUnicodeText

Is telling the title to center justify the title.  Check in the style you are using or put the style elements in yourself with:

titleattrs=(just=l)

DGrint
Obsidian | Level 7

Perhaps I wasn't clear, the title is left aligned but it is above the data values rather than above the data labels. How can I position it above the data labels?

 

test.png

WarrenKuhfeld
Rhodochrosite | Level 12

You have to use SG Annotation (or a draw statement).  I have examples at work.  I can dig them out later this morning.

WarrenKuhfeld
Rhodochrosite | Level 12

Here is an example of using PROC LIFETEST using techniques fromhttp://support.sas.com/documentation/onlinedoc/stat/142/kaplan.pdf .  I also show an SG annotation example, but outside the context of a KM plot.

data _null_;
   %let url = //support.sas.com/documentation/onlinedoc/stat;
   infile "http:&url/ex_code/143/templft.html" device=url;
   file 'macros.tmp';
   input;
   _infile_ = tranwrd(_infile_, '&amp;', '&');
   _infile_ = tranwrd(_infile_, '&lt;' , '<');
   if index(_infile_, '</pre>') then pre = 0;
   if pre then put _infile_;
   if index(_infile_, '<pre>')   then pre + 1;
run;

%inc 'macros.tmp' / nosource;

%ProvideSurvivalMacros

%macro StmtsBeginGraph; 
  * Coordinates are ad hoc, and there are many 
     available coordinate systems.
     See the documentation for more information.;
  drawtext textattrs=(weight=Bold) 'CD4<100 cells/(*ESC*){unicode mu}L' / 
                  x=8 y=14 width=20;
%mend;

%CompileSurvivalTemplates

ods html body='b.html';
ods graphics on;
proc lifetest data=sashelp.BMT 
                      plots=survival(atrisk outside maxlen=13);
   time T * Status(0);
   strata Group;
run;

data anno;
   label = 'CD4<100 cells/(*ESC*){unicode mu}L';
   function = 'text';
   drawspace = 'GraphPercent';
   x1 = 15;
   y1 = 5;
   width = 25;
run;

proc sgplot data=sashelp.class sganno=anno;
   scatter y=weight x=height;
run;

ods html close;
Jay54
Meteorite | Level 14

I am thinking one way to do this (without annotation) would be to add another class level, with the title you want, and provide missing values.  If you want the bold text, you could possibly use the TEXTGROUP.  This will line up this "title" right aligned with the other group values.  I have not tried it yet myself...

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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
  • 5 replies
  • 2382 views
  • 1 like
  • 4 in conversation