BookmarkSubscribeRSS Feed
knveraraju91
Barite | Level 11

Dear,

 

I posted this question in base location. I did not get nay reply. 

 

The output attached has a table below the graph which is truncated and not all 6 treatments are seen. Please help where i need to modify my code to get the full table. Thank you

 

I used below proc template code.

 

proc template;
define statgraph KM;
begingraph;
dynamic _prttlout _prttlin _prfntout _prfntin;
   if (_prttlout= 1) %do _cnt = 1 %to &_ttlout0; entrytitle "&&_ttlout&_cnt"; %end; endif;
   if (_prttlin = 1) %do _cnt = 1 %to &_ttlin0;  entrytitle textattrs=(style=normal size=11) "&&_ttlin&_cnt"; %end; endif;
   if (_prfntin = 1) %do _cnt = 1 %to &_fttin0;  entryfootnote halign=left "&&_fntin&_cnt"; %end; endif;
   if (_prfntout= 1) %do _cnt = 1 %to &_fttout0; entryfootnote halign=left "&&_fntout&_cnt"; %end; endif;

   layout lattice / columns=1 rowgutter=8 rowweights=(&_rowwght);
%if "&stats1" eq "Y" %then %do;
      layout gridded / columns=&cnt border=false;   
         entry " "; %do i = 1 %to &n_grp; entry "&&grp&i"; %end;
    %if "&_r1" eq "Y" %then %do; entry halign=right "Number of Subjects";       %do i=1 %to &n_grp; entry "&&total&i";    %end; %end;
    %if "&_r2" eq "Y" %then %do; entry halign=right "Number of Events";         %do i=1 %to &n_grp; entry "&&failed&i";   %end; %end;
    %if "&_r3" eq "Y" %then %do; entry halign=right "% of Events (95% CI)";     %do i=1 %to &n_grp; entry "&&failpci&i";  %end; %end;
    %if "&_r4" eq "Y" %then %do; entry halign=right "Survival Mean Time (SDE)"; %do i=1 %to &n_grp; entry "&&meansde&i";  %end; %end;
    %if "&_r5" eq "Y" %then %do; entry halign=right "Median Survival (95% CI)"; %do i=1 %to &n_grp; entry "&&medianci&i"; %end; %end;
      endlayout; 
%end;
      layout overlay / yaxisopts=(griddisplay=on offsetmin=0 linearopts=(viewmin=&_yvalmin viewmax=&_yvalmax tickvaluelist=(&_yvallst)
                                 /* minorticks=true*/) %if %sysevalf(%superq(y_label)^=,boolean) %then label="&y_label";) 
                       xaxisopts=(griddisplay=on offsetmin=0 linearopts=(viewmin=&_timemin viewmax=&_timemax tickvaluelist=(&x_order) 
                                  /*minorticks=true*/) %if %sysevalf(%superq(x_label)^=,boolean) %then label="&x_label";);
    %if "&display_label" ne "-1" %then %do;
        scatterplot x=lbltime y=y_&plot / group=&group_var datalabel=lbl_&plot;
    %end;
    %if "&bb_style" eq "BAND" or "&bb_style" eq "BOTH" %then %do;
        bandplot x=time LimitUpper=L&bb_type._&plot LimitLower=U&bb_type._&plot / group=&group_var datatransparency=0.7 modelName="s";
    %end;
    %if "&bb_style" eq "BAR" or "&bb_style" eq "BOTH" %then %do;
        scatterplot x=tabtime y=B_&plot / group=&group_var yerrorlower=B_L&bb_type._&plot yerrorupper=B_U&bb_type._&plot groupdisplay=cluster clusterwidth=0.15;
    %end;
        stepplot x=time y=&plot / group=&group_var name='s' primary=true;
	%if "&_censor_yn" eq "Y" %then %do;
        scatterplot x=time y=censor_&plot / group=&group_var markercharacter=censor_flag markercharacterattrs=(size=11);
    %end;
        layout gridded / autoalign=&_autoalign border=false;
/*          %if "&_censor_yn" eq "Y" %then %do; entry halign=center "&_censor_sb2 Censored"; %end;*/
          %if %sysevalf(%superq(display_pvalue)=Y,boolean) %then %do; entry halign=center "Log-Rank p=&log_rank_p"; %end;
          %if %sysevalf(%superq(n_grp)>1,boolean) %then %do; discretelegend 's' / valueattrs=(size=8) border=off location=inside across=1; %end;
        endlayout; 
   endlayout;

%if "&tab1var" ne "NONE" %then %do;
    layout overlay / walldisplay=NONE xaxisopts=(display=none 
                     linearopts=(viewmin=&_timemin viewmax=&_timemax tickvaluelist=(&x_order))) border=false ;
        entry halign=left "&tab1ttl" / location=outside valign=top textattrs=(weight=normal); 
        axistable x=tabtime value=&tab1var / class=&group_var display=(label) valueattrs=(size=9pt);
    endlayout;
%end;
%if "&tab2var" ne "NONE" %then %do;
    layout overlay / walldisplay=NONE xaxisopts=(display=none 
                     linearopts=(viewmin=&_timemin viewmax=&_timemax tickvaluelist=(&x_order))) border=false ;
        entry halign=left "&tab2ttl" / location=outside valign=top textattrs=(weight=bold); 
        axistable x=tabtime value=&tab2var / class=&group_var display=(label) valueattrs=(size=6pt);
    endlayout;
%end;
   endlayout;
endgraph;
end;
run;

%*** 5.3 generate the plot.;
%*** customized style changing size and stype of title/footnote font.;
proc template;
define style _myrtf_;
parent = &_style ;
style fonts /
     'TitleFont2' = ("Times New Roman, Times, Arial",11pt,normal)             
     'TitleFont' = ("Times New Roman, Times, Arial",11pt,normal)              
     'StrongFont' = ("Times New Roman, Times, Arial",10pt,bold)                    
     'EmphasisFont' = ("Times New Roman, Times, Arial",10pt,italic)                
     'FixedEmphasisFont' = ("<monospace>, Courier",9pt,italic)            
     'FixedStrongFont' = ("<monospace>, Courier",9pt,bold)                
     'FixedHeadingFont' = ("<monospace>, Courier",9pt,bold)               
     'BatchFixedFont' = ("SAS Monospace, <monospace>, Courier",7pt)     
     'FixedFont' = ("<monospace>, Courier",9pt)                           
     'headingEmphasisFont' = ("<serif>, Times New Roman, Times",11pt,bold italic)    
     'headingFont' = ("<serif>, Times New Roman, Times",11pt,bold)                   
     'docFont' = ("<serif>, Times New Roman, Times",10pt);                   
end;
run;
7 REPLIES 7
pau13rown
Lapis Lazuli | Level 10

could be a number of things eg make it landscape?: "options orientation=landscape"

 

there is a problem opening your attachment so I cannot see exactly what the issue is

knveraraju91
Barite | Level 11

Thank you for your response. I am attaching the doc again. Thank you

knveraraju91
Barite | Level 11

Hi

 

the 'orientation' option did not work.

 

But I try explain the issue. 

 

In my program if I use character variable (eg:trta) as my group variable i am getting the output I need with out truncation. But i did not use the character variable as my group variable, because of the TRTA variable values, i am unable to get sort order in my legend and table (below the graph) as cohort A, cohort B,cohort C,  cohort D, cohort E,, cohort F.

 

I am getting  cohort D, cohort B,cohort A,  cohort C, cohort D, cohort S. in the legend and table.

 

So i used numeric variable(trtan) as my group variable and format it. In the out put i am getting truncated table with only 4 treatments appearing in the output instead of 6. Please help me how to get the sort order i need in the output. Thank you.

 

TRTA

amksks(cohort A)

alksks(cohort B)

apksks(cohort C)

acksks(cohort D)

arksks(cohort E)

asksks(cohort F)

 

pau13rown
Lapis Lazuli | Level 10

i see what you're saying. This is a very common figure in medical research so there should be some code out there to do it for you. Personally I have always used the "annotate=" option on the plot statement in proc gplot. I may be a bit out of touch tho. See section 4.5.1 (" Survival Plot with External "Subjects At-Risk" Table") in this free ebook: http://support.sas.com/publishing/vds.pdf

Jay54
Meteorite | Level 14

Your code is quite complex for a survival plot.  Have you seen these blog articles?  It can provide you some hints.  With SAS 9.4, you can use the AXISTABLE to display the "At Risk" table.

 

https://blogs.sas.com/content/graphicallyspeaking/2018/02/19/survival-plot-twist-using-sgplot-proced...

https://blogs.sas.com/content/graphicallyspeaking/2014/02/09/survival-plot/

 

JeffMeyers
Barite | Level 11

Can you post a snap shot of your data that you are using with the template? It would be good to check if your issue is with the data instead of the template. You are using an axis table with the class statement, so there could be a chance your other treatment groups aren't actually in the data you are using.

 

Just to put this out there as well, I have a rather strong macro that can do most of what you're trying to do if you would like to try it out:

http://www.sascommunity.org/wiki/Kaplan-Meier_Survival_Plotting_Macro_%25NEWSURV

knveraraju91
Barite | Level 11

Thank you very much. I think i got what i need in my graph. I used 'classorder=data'  option in program.Thank you

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 7 replies
  • 1923 views
  • 4 likes
  • 4 in conversation