Data visualization with SAS programming

xaxistable title

Accepted Solution Solved
Reply
Contributor
Posts: 22
Accepted Solution

xaxistable title

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;

Accepted Solutions
Solution
‎01-17-2018 05:23 AM
SAS Super FREQ
Posts: 496

Re: xaxistable title

Posted in reply to WarrenKuhfeld

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


All Replies
Super User
Super User
Posts: 9,193

Re: xaxistable title

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)

Contributor
Posts: 22

Re: xaxistable title

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

SAS Super FREQ
Posts: 496

Re: xaxistable title

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

Solution
‎01-17-2018 05:23 AM
SAS Super FREQ
Posts: 496

Re: xaxistable title

Posted in reply to WarrenKuhfeld

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;
SAS Super FREQ
Posts: 1,263

Re: xaxistable title

[ Edited ]

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

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 5 replies
  • 166 views
  • 1 like
  • 4 in conversation