BookmarkSubscribeRSS Feed
greg_maislin
Fluorite | Level 6

Hi All,

Using the SAS Institute PROC LIFETEST Template I can modify the y-axis to remove extra white space given that survival is >75% in both groups.  I also can modify the ticks on the x-axis, etc.    But I want a cumulative mortality curve not a survival curve.  According to documentation that I've found, all I have to do is change:

Stat.Lifetest.Graphics.ProductLimitSurvival%scan(2,2-&outside);

To:

Stat.Lifetest.Graphics.ProductLimitFailure%scan(2,2-&outside);

 

And then make the appropriate changes to %let statement between

%ProvideSurvivalMacros

and

%CompileSurvivalTemplates

 

The only difference is in the %let for yOptions, the first for survival and the second for failure:

 

*%let yOptions = label="Survival Probability" shortlabel="Survival"

 

linearopts=(viewmin=.75 viewmax=1

tickvaluelist=(.7 .75 .8 .85 .9 .95 1));

 

%let yOptions = label="Cumulative Mortality" shortlabel="Mortality"

 

linearopts=(viewmin=0 viewmax=0.25

tickvaluelist=(0 0.05 0.10 0.15 0.20 0.25));

 

When I do this, there is no data in the K-M plot, although my options appeared to be implemented.  When I delete the failure templates and re-run the proc I get the failure distributions plotted, but without my preferred options, of course.

 

I have no trouble getting what I want for the survival curves?

 

Am I missing something on how to modify the y-axis for failure curves without losing the data points in the graphs?

 

I just can't figure this one out.   Hopefully, someone might have experienced this issues and figured out how to do this.

 

Greg Maislin

Adjunct Professor of Statistics in Medicine

Perelman School of Medicine

University of Pennsylvania

 

9 REPLIES 9
Reeza
Super User
Can you include your full code and log please?
greg_maislin
Fluorite | Level 6

Code:

title3 'gm_Mortality_Day90.sas';
proc format;
 value $suc 1='aSuccess' 2='bFailure';
 value bmi_cat 1='a<30' 2='b30-40' 3='c>40';
 value yn10fmt 1='aYes' 0='bNo';
 value $yn10fmt 1='aYes' 0='bNo';
 value grp 1='aReltec.' 2='bPlacebo';
 value censor 1='bNo Death' 0='aDeath';
 run;
 
%macro timevarprint();
data hr2;
 set hr;
 HR=exp(ESTIMATE);
 lb=exp(estimate-1.96*STDERR);
 ub=exp(estimate+1.96*STDERR);
 run;
title6 "Hazard Ratio Post Day 14";
proc print data=hr2;
run;
%mend;
 
 
data at;
 set sasdat.effshort;
 if group4=1 ;
  
 censor_mort90 = censor; drop censor;
 days_mort90 = ttime ; drop ttime;
 if days_mort90>90 then do days_mort90=90 ;  /*there is an 852*/
 censor_mort90=1;
 end;
 label
 nfail='Renal fail'
 rfail='Resp. fail'
 ;
 if bmilt30=1 then bmi_cat=1;
 if bmige40=1 then bmi_cat=3;
 if bmi30lt40=1 then bmi_cat=2;
 format bmi_cat bmi_cat. ;
 if site in ("01 Limoges", "03 Creteil", "05 Lille", "06 Lyon", "07 Nancy") then french=1;
 else french=0;
 format french bmige40 bmilt30 CCGANG CKD nfail rfail cfail /*fgang*/ ccgang ccnfasc aki_st3 aki_stg0 bmige40 yn10fmt.
 group grp. nicce $suc. censor_mort14 censor_mort28 censor_mort90 censor. fgang $yn10fmt. eff4 eff5 $suc.;

 if group=1 then control=0;
 if group=2 then control=1;
 run;
 

data modpp;
 set at;
 if modppexc ne 1;
 run;
 

/****************************************************************/
/*          S A S   S A M P L E   L I B R A R Y                 */
/*                                                              */
/*    NAME: TEMPLFT                                             */
/*   TITLE: PROC LIFETEST Template                              */
/* PRODUCT: STAT                                                */
/*  SYSTEM: ALL                                                 */
/*    KEYS: graphics, ods, survival analysis, Kaplan-Meier      */
/*   PROCS:                                                     */
/*    DATA:                                                     */
/*                                                              */
/* SUPPORT: saswfk                UPDATE: July 25, 2013         */
/*     REF: ods graphics                                        */
/*    MISC:                                                     */
/*   NOTES: This sample provides templates for the PROC         */
/*          LIFETEST survival plot that are modular and         */
/*          easier to modify than the default templates.        */
/****************************************************************/
%macro ProvideSurvivalMacros;
   %global atriskopts bandopts censored censorstr classopts
           graphopts groups insetopts legendopts ntitles stepopts tiplabel
           tips titletext0 titletext1 titletext2 xoptions yoptions;
   %let TitleText0 = METHOD " Survival Estimate";
   %let TitleText1 = &titletext0 " for " STRATUMID;
   %let TitleText2 = &titletext0 "s";         /* plural: Survival Estimates */
   %let nTitles    = 2;

   %let yOptions   = label="Survival Probability" shortlabel="Survival"
                     linearopts=(viewmin=0 viewmax=1
                                 tickvaluelist=(0 .2 .4 .6 .8 1.0));
 
   %let xOptions   = shortlabel=XNAME offsetmin=.05
                     linearopts=(viewmax=MAXTIME tickvaluelist=XTICKVALS
                                 tickvaluefitpolicy=XTICKVALFITPOL);
   %let Tips       = rolename=(_tip1= ATRISK _tip2=EVENT)
                     tiplabel=(_tip1="Number at Risk" _tip2="Observed Events")
                     tip=(x y _tip1 _tip2);
   %let TipLabel   = tiplabel=(y="Survival Probability");
   %let StepOpts   = ;
   %let Groups     = group=STRATUM index=STRATUMNUM;
   %let BandOpts   = displayTail=false &groups modelname="Survival";
   %let InsetOpts  = autoalign=(TOPRIGHT BOTTOMLEFT TOP BOTTOM)
                     border=true BackgroundColor=GraphWalls:Color Opaque=true;
   %let LegendOpts = title=GROUPNAME location=outside;
   %let AtRiskOpts = display=(label) valueattrs=(size=7pt);
   %let ClassOpts  = class=CLASSATRISK colorgroup=CLASSATRISK;
   %let Censored   = markerattrs=(symbol=plus);
   %let CensorStr  = "+ Censored";
   %let GraphOpts  = ;
   %macro StmtsBeginGraph; %mend;
   %macro StmtsTop;        %mend;
   %macro StmtsBottom;     %mend;
   %macro CompileSurvivalTemplates;
      %local outside;
      proc template;
         %do outside = 0 %to 1;
            define statgraph
              
      Stat.Lifetest.Graphics.ProductLimitFailure%scan(2,2-&outside);   /*HERE IS CHANGE: ProductLimitSurvival to ProductLimitFailure*/
               dynamic NStrata xName plotAtRisk
                  %if %nrbquote(&censored) ne %then plotCensored;
                  plotCL plotHW plotEP labelCL labelHW labelEP maxTime xtickVals
                  xtickValFitPol rowWeights method StratumID classAtRisk
                  plotTest GroupName Transparency SecondTitle TestName pValue
                  _byline_ _bytitle_ _byfootnote_;
               BeginGraph %if %nrbquote(&graphopts) ne %then / &graphopts;;
               if (NSTRATA=1)
                  %if &ntitles %then %do;
                     if (EXISTS(STRATUMID)) entrytitle &titletext1;
                     else                   entrytitle &titletext0;
                     endif;
                  %end;
                  %if &ntitles gt 1 %then %do;
                     %if not &outside %then if (PLOTATRISK=1);
                        entrytitle "With Number of Subjects at Risk" /
                                   textattrs=GRAPHVALUETEXT;
                     %if not &outside %then %do; endif; %end;
                  %end;
                  %StmtsBeginGraph
                  %AtRiskLatticeStart
                  layout overlay / xaxisopts=(&xoptions) yaxisopts=(&yoptions);
                     %StmtsTop
                     %SingleStratum
                     %StmtsBottom
                  endlayout;
                  %AtRiskLatticeEnd
               else
                  %if &ntitles %then %do; entrytitle &titletext2; %end;
                  %if &ntitles gt 1 %then %do;
                     if (EXISTS(SECONDTITLE))
                        entrytitle SECONDTITLE / textattrs=GRAPHVALUETEXT;
                     endif;
                  %end;
                  %StmtsBeginGraph
                  %AtRiskLatticeStart
                  layout overlay / xaxisopts=(&xoptions) yaxisopts=(&yoptions);
                     %StmtsTop
                     %MultipleStrata
                     %StmtsBottom
                  endlayout;
                  %AtRiskLatticeEnd(class)
               endif;
               if (_BYTITLE_) entrytitle _BYLINE_ / textattrs=GRAPHVALUETEXT;
               else if (_BYFOOTNOTE_) entryfootnote halign=left _BYLINE_; endif;
               endif;
               EndGraph;
            end;
         %end;
      run;
   %mend;
   %macro pValue;
      if (PVALUE < .0001)
         entry TESTNAME " p " eval (PUT(PVALUE, PVALUE6.4));
      else
         entry TESTNAME " p=" eval (PUT(PVALUE, PVALUE6.4));
      endif;
   %mend;
   %macro SingleStratum;
      if (PLOTHW=1 AND PLOTEP=0)
         bandplot LimitUpper=HW_UCL LimitLower=HW_LCL x=TIME /
            displayTail=false modelname="Survival" fillattrs=GRAPHCONFIDENCE
            name="HW" legendlabel=LABELHW;
      endif;
      if (PLOTHW=0 AND PLOTEP=1)
         bandplot LimitUpper=EP_UCL LimitLower=EP_LCL x=TIME /
            displayTail=false modelname="Survival" fillattrs=GRAPHCONFIDENCE
            name="EP" legendlabel=LABELEP;
      endif;
      if (PLOTHW=1 AND PLOTEP=1)
         bandplot LimitUpper=HW_UCL LimitLower=HW_LCL x=TIME /
            displayTail=false modelname="Survival" fillattrs=GRAPHDATA1
            datatransparency=.55 name="HW" legendlabel=LABELHW;
         bandplot LimitUpper=EP_UCL LimitLower=EP_LCL x=TIME /
            displayTail=false modelname="Survival" fillattrs=GRAPHDATA2
            datatransparency=.55 name="EP" legendlabel=LABELEP;
      endif;
      if (PLOTCL=1)
         if (PLOTHW=1 OR PLOTEP=1)
            bandplot LimitUpper=SDF_UCL LimitLower=SDF_LCL x=TIME /
               displayTail=false modelname="Survival" display=(outline)
               outlineattrs=GRAPHPREDICTIONLIMITS name="CL" legendlabel=LABELCL;
         else
            bandplot LimitUpper=SDF_UCL LimitLower=SDF_LCL x=TIME /
               displayTail=false modelname="Survival" fillattrs=GRAPHCONFIDENCE
               name="CL" legendlabel=LABELCL;
         endif;
      endif;
      stepplot y=SURVIVAL x=TIME / name="Survival" &tips legendlabel="Survival"
               &stepopts;
      if (PLOTCENSORED=1)
         scatterplot y=CENSORED x=TIME / &censored &tiplabel
            name="Censored" legendlabel="Censored";
      endif;
      if (PLOTCL=1 OR PLOTHW=1 OR PLOTEP=1)
         discretelegend "Censored" "CL" "HW" "EP" / location=outside
            halign=center;
      else
         if (PLOTCENSORED=1)
            discretelegend "Censored" / location=inside
                                        autoalign=(topright bottomleft);
         endif;
      endif;
      %if not &outside %then %do;
         if (PLOTATRISK=1)
            innermargin / align=bottom;
               axistable x=TATRISK value=ATRISK / &atriskopts;
            endinnermargin;
         endif;
      %end;
   %mend;
   %macro MultipleStrata;
     if (PLOTHW=1)
         bandplot LimitUpper=HW_UCL LimitLower=HW_LCL x=TIME / &bandopts
                  datatransparency=Transparency;
      endif;
      if (PLOTEP=1)
         bandplot LimitUpper=EP_UCL LimitLower=EP_LCL x=TIME / &bandopts
                  datatransparency=Transparency;
      endif;
      if (PLOTCL=1)
         if (PLOTHW=1 OR PLOTEP=1)
            bandplot LimitUpper=SDF_UCL LimitLower=SDF_LCL x=TIME / &bandopts
                     display=(outline) outlineattrs=(pattern=ShortDash);
         else
            bandplot LimitUpper=SDF_UCL LimitLower=SDF_LCL x=TIME / &bandopts
                     datatransparency=Transparency;
         endif;
      endif;
      stepplot y=SURVIVAL x=TIME / &groups name="Survival" &tips &stepopts;
      if (PLOTCENSORED=1)
         scatterplot y=CENSORED x=TIME / &groups &tiplabel &censored;
      endif;
      %if not &outside %then %do;
         if (PLOTATRISK=1)
            innermargin / align=bottom;
               axistable x=TATRISK value=ATRISK / &atriskopts &classopts;
            endinnermargin;
         endif;
      %end;
      %if %nrbquote(&legendopts) ne %then %do;
         DiscreteLegend "Survival" / &legendopts;
      %end;
      %if %nrbquote(&insetopts) ne %then %do;
         if (PLOTCENSORED=1)
            if (PLOTTEST=1)
               layout gridded / rows=2 &insetopts;
                  entry &censorstr;
                  %pValue
               endlayout;
            else
               layout gridded / rows=1 &insetopts;
                  entry &censorstr;
               endlayout;
            endif;
         else
            if (PLOTTEST=1)
               layout gridded / rows=1 &insetopts;
                  %pValue
               endlayout;
            endif;
         endif;
         %end;
   %mend;
   %macro SurvTabHeader(multiple);
      %if &multiple %then %do; entry ""; %end;
      entry "";
      entry "";
      entry "";
      entry &r "Median";
      entry "";
      entry "";
      %if &multiple %then %do; entry ""; %end;
      entry &r "Subjects";
      entry &r "Event";
      entry &r "Censored";
      entry &r "Survival";
      entry &r PctMedianConfid;
      entry halign=left  "CL";
   %mend;
   %macro SurvivalTable;
      %local fmt r i t;
      %let fmt = bestd6.;
      %let r = halign = right;
      columnheaders;
         layout overlay / pad=(top=5);
            if(NSTRATA=1)
               layout gridded / columns=6 border=TRUE;
                  dynamic PctMedianConfid NObs NEvent Median
                          LowerMedian UpperMedian;
                  %SurvTabHeader(0)
                  entry &r NObs;
                  entry &r NEvent;
                  entry &r eval(NObs-NEvent);
                  entry &r eval(put(Median,&fmt));
                  entry &r eval(put(LowerMedian,&fmt));
                  entry &r eval(put(UpperMedian,&fmt));
               endlayout;
            else
               layout gridded / columns=7 border=TRUE;
                  dynamic PctMedianConfid;
                  %SurvTabHeader(1)
                  %do i = 1 %to 10;
                     %let t = / textattrs=GraphData&i;
                     dynamic StrVal&i NObs&i NEvent&i Median&i
                             LowerMedian&i UpperMedian&i;
                     if (&i <= nstrata)
                        entry &r StrVal&i &t;
                        entry &r NObs&i &t;
                        entry &r NEvent&i &t;
                        entry &r eval(NObs&i-NEvent&i) &t;
                        entry &r eval(put(Median&i,&fmt)) &t;
                        entry &r eval(put(LowerMedian&i,&fmt)) &t;
                        entry &r eval(put(UpperMedian&i,&fmt)) &t;
                     endif;
                  %end;
               endlayout;
            endif;
         endlayout;
      endcolumnheaders;
   %mend;
   %macro SurvivalSummaryTable;
      %macro AtRiskLatticeStart;
         layout lattice / columndatarange=union rowgutter=10
            rows=%if &outside %then 2 rowweights=ROWWEIGHTS;
                 %else              1;;
         %if &outside %then %do; cell; %end;
      %mend;
      %macro AtRiskLatticeEnd(useclassopts);
         %if &outside %then %do;
            endcell;
            cell;
               layout overlay / walldisplay=none xaxisopts=(display=none);
                  axistable x=TATRISK value=ATRISK / &atriskopts
                            %if &useclassopts ne %then &classopts;;
               endlayout;
            endcell;
         %end;
         %SurvivalTable
         endlayout;
      %mend;
   %mend;
   %macro AtRiskLatticeStart;
      %if &outside %then %do;
         layout lattice / rows=2 rowweights=ROWWEIGHTS
                          columndatarange=union rowgutter=10;
         cell;
      %end;
   %mend;
   %macro AtRiskLatticeEnd(useclassopts);
      %if &outside %then %do;
         endcell;
         cell;
            layout overlay / walldisplay=none xaxisopts=(display=none);
               axistable x=TATRISK value=ATRISK / &atriskopts
                         %if &useclassopts ne %then &classopts;;
            endlayout;
         endcell;
      endlayout;
      %end;
   %mend;
%CompileSurvivalTemplates
%mend;
 
/*
proc template;
   delete Stat.Lifetest.Graphics.ProductLimitSurvival  /
          store=sasuser.templat;
   delete Stat.Lifetest.Graphics.ProductLimitSurvival2 /
          store=sasuser.templat;
run;
proc template;
   delete Stat.Lifetest.Graphics.ProductLimitFailure  /
          store=sasuser.templat;
   delete Stat.Lifetest.Graphics.ProductLimitFailure2 /
          store=sasuser.templat;
run;
*/

*********************************************************************************************;
* PP all days ;
*********************************************************************************************;

filename out1 "&dir&client&project\output\gm_Mortality_Day90 2019-11-16.rtf";

title3 'gm_Mortality_Day90.sas';
ods rtf file=out1;
options pageno=1;

%ProvideSurvivalMacros
   %let yOptions   = label="Survival Probability" shortlabel="Survival"
                     linearopts=(viewmin=.75 viewmax=1
                                 tickvaluelist=(.7 .75 .8 .85 .9 .95 1));

  * %let yOptions   = label="Cumulative Mortality" shortlabel="Mortality"
                     linearopts=(viewmin=0 viewmax=1
                                 tickvaluelist=(0 .2 .4 .6 .8 1.0));

 %let xOptions   = shortlabel=XNAME offsetmin=.05
                     linearopts=(viewmax=MAXTIME tickvaluelist=(0 7 14 21 28 35 42 49 56 63 70 77 84 91)
                                 tickvaluefitpolicy=XTICKVALFITPOL);
%let TitleText2 = "Kaplan-Meier Plot in Per Protocol Analysis Set";
%let LegendOpts = title="+ Censored"
                  location=inside autoalign=(Bottom);
*%let InsetOpts  = ;

%macro StmtsBottom;
   dynamic %do i = 1 %to 3; StrVal&i NObs&i NEvent&i %end;;
   layout gridded / columns=3 border=TRUE autoalign=(Top);
      entry ""; entry "Event"; entry "Total";
      %do i = 1 %to 3;
         %let t = / textattrs=GraphData&i;
         entry halign=right Strval&i &t; entry NEvent&i &t; entry NObs&i &t;
      %end;
   endlayout;
%mend;
%let GraphOpts = DesignHeight=DefaultDesignWidth;

%macro pValue;
   if (PVALUE < .0001)
      entry "Log Rank p "   eval (PUT(PVALUE, PVALUE6.4));
   else
      entry "Log Rank p = " eval (PUT(PVALUE, PVALUE6.4));
   endif;
%mend;

*%SurvivalSummaryTable;

%CompileSurvivalTemplates

proc format;
 value group 1='Relticimod' 2='Placebo';
 run;
 
title4 'Kaplan-Meier Survival to Day 90 in Per Protocol Analysis Set';
proc lifetest data=modPP  rmst plots= survival ( test atrisk = 1 to 90 by 7 /*cb=hw*/) timelist = 1,2,3,4,5,6,7,14,21,28,60,90 ;
time days_mort90*censor_mort90(1);
strata group /order=internal;
label group='Dose Group';
label days_mort90='Days to Death or Censor';
format group group.;
run;
/*Need to first edit SAS provided macro changing ProductLimitSurvival to ProductLimitFailure*/
%ProvideSurvivalMacros
   *%let yOptions   = label="Survival Probability" shortlabel="Survival"
                     linearopts=(viewmin=.75 viewmax=1
                                 tickvaluelist=(.7 .75 .8 .85 .9 .95 1));

   %let yOptions   = label="Cumulative Mortality" shortlabel="Mortality"
                     linearopts=(viewmin=0 viewmax=0.25
                                 tickvaluelist=(0 0.05 0.10 0.15 0.20 0.25));

 %let xOptions   = shortlabel=XNAME offsetmin=.05
                     linearopts=(viewmax=MAXTIME tickvaluelist=(0 7 14 21 28 35 42 49 56 63 70 77 84 91)
                                 tickvaluefitpolicy=XTICKVALFITPOL);
%let TitleText2 = "Kaplan-Meier Plot in Per Protocol Analysis Set";
%let LegendOpts = title="+ Censored"
                  location=inside autoalign=(Bottom);
*%let InsetOpts  = ;

%macro StmtsBottom;
   dynamic %do i = 1 %to 3; StrVal&i NObs&i NEvent&i %end;;
   layout gridded / columns=3 border=TRUE autoalign=(Top);
      entry ""; entry "Event"; entry "Total";
      %do i = 1 %to 3;
         %let t = / textattrs=GraphData&i;
         entry halign=right Strval&i &t; entry NEvent&i &t; entry NObs&i &t;
      %end;
   endlayout;
%mend;
%let GraphOpts = DesignHeight=DefaultDesignWidth;

%macro pValue;
   if (PVALUE < .0001)
      entry "Log Rank p "   eval (PUT(PVALUE, PVALUE6.4));
   else
      entry "Log Rank p = " eval (PUT(PVALUE, PVALUE6.4));
   endif;
%mend;

*%SurvivalSummaryTable;

%CompileSurvivalTemplates
 
title4 'Kaplan-Meier Cumulative Failure to Day 90 in Per Protocol Analysis Set';
proc lifetest data=modPP  rmst plots= survival ( failure test atrisk = 1 to 90 by 7 /*cb=hw*/) timelist = 1,2,3,4,5,6,7,14,21,28,60,90 ;
time days_mort90*censor_mort90(1);
strata group /order=internal;
label group='Dose Group';
label days_mort90='Days to Death or Censor';
format group group.;
run;
 
ods rtf close;
 
 
/***********LOG****************************/
/*RUN after changing to Stat.Lifetest.Graphics.ProductLimitFailure%scan(2,2-&outside);
 
NOTE: Copyright (c) 2016 by SAS Institute Inc., Cary, NC, USA.
NOTE: SAS (r) Proprietary Software 9.4 (TS1M6)
      Licensed to UNIVERSITY OF PENNSYLVANIA - SFA T&R, Site 70080524.
NOTE: This session is executing on the X64_10PRO  platform.
 
NOTE: Analytical products:
      SAS/STAT 15.1
      SAS/ETS 15.1
      SAS/OR 15.1
      SAS/IML 15.1
      SAS/QC 15.1
NOTE: Additional host information:
 X64_10PRO WIN 10.0.17763  Workstation
NOTE: SAS initialization used:
      real time           3.12 seconds
      cpu time            1.17 seconds
2710
2711  title3 'gm_Mortality_Day90.sas';
2712
2713  proc format;
2714   value $suc 1='aSuccess' 2='bFailure';
NOTE: Format $SUC is already on the library WORK.FORMATS.
NOTE: Format $SUC has been output.
2715   value bmi_cat 1='a<30' 2='b30-40' 3='c>40';
NOTE: Format BMI_CAT is already on the library WORK.FORMATS.
NOTE: Format BMI_CAT has been output.
2716   value yn10fmt 1='aYes' 0='bNo';
NOTE: Format YN10FMT is already on the library WORK.FORMATS.
NOTE: Format YN10FMT has been output.
2717   value $yn10fmt 1='aYes' 0='bNo';
NOTE: Format $YN10FMT is already on the library WORK.FORMATS.
NOTE: Format $YN10FMT has been output.
2718   value grp 1='aReltec.' 2='bPlacebo';
NOTE: Format GRP is already on the library WORK.FORMATS.
NOTE: Format GRP has been output.
2719   value censor 1='bNo Death' 0='aDeath';
NOTE: Format CENSOR is already on the library WORK.FORMATS.
NOTE: Format CENSOR has been output.
2720
2721      run;
NOTE: PROCEDURE FORMAT used (Total process time):
      real time           0.01 seconds
      cpu time            0.01 seconds

2722
2723  %macro timevarprint();
2724  data hr2;
2725      set hr;
2726      HR=exp(ESTIMATE);
2727      lb=exp(estimate-1.96*STDERR);
2728      ub=exp(estimate+1.96*STDERR);
2729      run;
2730  title6 "Hazard Ratio Post Day 14";
2731  proc print data=hr2;
2732  run;
2733  %mend;
2734
2735
2736
2737
2738  data at;
2739      set sasdat.effshort;
2740      if group4=1 ;
2741
2742      censor_mort90 = censor; drop censor;
2743      days_mort90 = ttime ; drop ttime;
2744
2745      if days_mort90>90 then do days_mort90=90 ;  /*there is an 852*/
2746      censor_mort90=1;
2747      end;
2748
2749      label
2750      nfail='Renal fail'
2751      rfail='Resp. fail'
2752      ;
2753
2754      if bmilt30=1 then bmi_cat=1;
2755      if bmige40=1 then bmi_cat=3;
2756      if bmi30lt40=1 then bmi_cat=2;
2757      format bmi_cat bmi_cat. ;
2758
2759      if site in ("01 Limoges", "03 Creteil", "05 Lille", "06 Lyon", "07
2759!  Nancy") then french=1;
2760      else french=0;
2761
2762      format french bmige40 bmilt30 CCGANG CKD nfail rfail cfail
2762! /*fgang*/ ccgang ccnfasc aki_st3 aki_stg0 bmige40 yn10fmt.
2763      group grp. nicce $suc. censor_mort14 censor_mort28 censor_mort90
2763! censor. fgang $yn10fmt. eff4 eff5 $suc.;
2764
2765
2766      if group=1 then control=0;
2767      if group=2 then control=1;
2768      run;
NOTE: There were 290 observations read from the data set SASDAT.EFFSHORT.
NOTE: The data set WORK.AT has 290 observations and 928 variables.
NOTE: DATA statement used (Total process time):
      real time           0.07 seconds
      cpu time            0.04 seconds

2769
2770
2771
2772
2773  data modpp;
2774      set at;
2775      if modppexc ne 1;
2776      run;
NOTE: There were 290 observations read from the data set WORK.AT.
NOTE: The data set WORK.MODPP has 271 observations and 928 variables.
NOTE: DATA statement used (Total process time):
      real time           0.03 seconds
      cpu time            0.03 seconds

2777
2778
2779
2780
2781  /****************************************************************/
2782  /*          S A S   S A M P L E   L I B R A R Y                 */
2783  /*                                                              */
2784  /*    NAME: TEMPLFT                                             */
2785  /*   TITLE: PROC LIFETEST Template                              */
2786  /* PRODUCT: STAT                                                */
2787  /*  SYSTEM: ALL                                                 */
2788  /*    KEYS: graphics, ods, survival analysis, Kaplan-Meier      */
2789  /*   PROCS:                                                     */
2790  /*    DATA:                                                     */
2791  /*                                                              */
2792  /* SUPPORT: saswfk                UPDATE: July 25, 2013         */
2793  /*     REF: ods graphics                                        */
2794  /*    MISC:                                                     */
2795  /*   NOTES: This sample provides templates for the PROC         */
2796  /*          LIFETEST survival plot that are modular and         */
2797  /*          easier to modify than the default templates.        */
2798  /****************************************************************/
2799
2800  %macro ProvideSurvivalMacros;
2801
2802     %global atriskopts bandopts censored censorstr classopts
2803             graphopts groups insetopts legendopts ntitles stepopts
2803! tiplabel
2804             tips titletext0 titletext1 titletext2 xoptions yoptions;
2805
2806     %let TitleText0 = METHOD " Survival Estimate";
2807     %let TitleText1 = &titletext0 " for " STRATUMID;
2808     %let TitleText2 = &titletext0 "s";         /* plural: Survival
2808! Estimates */
2809     %let nTitles    = 2;
2810
2811
2812     %let yOptions   = label="Survival Probability"
2812! shortlabel="Survival"
2813                       linearopts=(viewmin=0 viewmax=1
2814                                   tickvaluelist=(0 .2 .4 .6 .8 1.0));
2815
2816
2817
2818     %let xOptions   = shortlabel=XNAME offsetmin=.05
2819                       linearopts=(viewmax=MAXTIME
2819! tickvaluelist=XTICKVALS
2820                                   tickvaluefitpolicy=XTICKVALFITPOL);
2821
2822     %let Tips       = rolename=(_tip1= ATRISK _tip2=EVENT)
2823                       tiplabel=(_tip1="Number at Risk" _tip2="Observed
2823! Events")
2824                       tip=(x y _tip1 _tip2);
2825     %let TipLabel   = tiplabel=(y="Survival Probability");
2826     %let StepOpts   = ;
2827
2828     %let Groups     = group=STRATUM index=STRATUMNUM;
2829
2830     %let BandOpts   = displayTail=false &groups modelname="Survival";
2831
2832     %let InsetOpts  = autoalign=(TOPRIGHT BOTTOMLEFT TOP BOTTOM)
2833                       border=true BackgroundColor=GraphWalls:Color
2833! Opaque=true;
2834     %let LegendOpts = title=GROUPNAME location=outside;
2835
2836     %let AtRiskOpts = display=(label) valueattrs=(size=7pt);
2837     %let ClassOpts  = class=CLASSATRISK colorgroup=CLASSATRISK;
2838
2839     %let Censored   = markerattrs=(symbol=plus);
2840     %let CensorStr  = "+ Censored";
2841
2842     %let GraphOpts  = ;
2843
2844     %macro StmtsBeginGraph; %mend;
2845     %macro StmtsTop;        %mend;
2846     %macro StmtsBottom;     %mend;
2847
2848     %macro CompileSurvivalTemplates;
2849        %local outside;
2850        proc template;
2851           %do outside = 0 %to 1;
2852              define statgraph
2853
2854                 Stat.Lifetest.Graphics.ProductLimitFailure%scan(2,2-&ou
2854! tside);   /*HERE IS CHANGE: ProductLimitSurvival to
2854! ProductLimitFailure*/
2855                 dynamic NStrata xName plotAtRisk
2856                    %if %nrbquote(&censored) ne %then plotCensored;
2857                    plotCL plotHW plotEP labelCL labelHW labelEP maxTime
2857!  xtickVals
2858                    xtickValFitPol rowWeights method StratumID
2858! classAtRisk
2859                    plotTest GroupName Transparency SecondTitle TestName
2859!  pValue
2860                    _byline_ _bytitle_ _byfootnote_;
2861                 BeginGraph %if %nrbquote(&graphopts) ne %then /
2861! &graphopts;;
2862
2863                 if (NSTRATA=1)
2864                    %if &ntitles %then %do;
2865                       if (EXISTS(STRATUMID)) entrytitle &titletext1;
2866                       else                   entrytitle &titletext0;
2867                       endif;
2868                    %end;
2869
2870                    %if &ntitles gt 1 %then %do;
2871                       %if not &outside %then if (PLOTATRISK=1);
2872                          entrytitle "With Number of Subjects at Risk" /
2873                                     textattrs=GRAPHVALUETEXT;
2874                       %if not &outside %then %do; endif; %end;
2875                    %end;
2876
2877                    %StmtsBeginGraph
2878                    %AtRiskLatticeStart
2879                    layout overlay / xaxisopts=(&xoptions)
2879! yaxisopts=(&yoptions);
2880                       %StmtsTop
2881                       %SingleStratum
2882                       %StmtsBottom
2883                    endlayout;
2884                    %AtRiskLatticeEnd
2885
2886                 else
2887                    %if &ntitles %then %do; entrytitle &titletext2; %end
2887! ;
2888                    %if &ntitles gt 1 %then %do;
2889                       if (EXISTS(SECONDTITLE))
2890                          entrytitle SECONDTITLE /
2890! textattrs=GRAPHVALUETEXT;
2891                       endif;
2892                    %end;
2893
2894                    %StmtsBeginGraph
2895                    %AtRiskLatticeStart
2896                    layout overlay / xaxisopts=(&xoptions)
2896! yaxisopts=(&yoptions);
2897                       %StmtsTop
2898                       %MultipleStrata
2899                       %StmtsBottom
2900                    endlayout;
2901                    %AtRiskLatticeEnd(class)
2902
2903                 endif;
2904
2905                 if (_BYTITLE_) entrytitle _BYLINE_ /
2905! textattrs=GRAPHVALUETEXT;
2906                 else if (_BYFOOTNOTE_) entryfootnote halign=left
2906! _BYLINE_; endif;
2907                 endif;
2908                 EndGraph;
2909              end;
2910           %end;
2911        run;
2912     %mend;
2913
2914     %macro pValue;
2915        if (PVALUE < .0001)
2916           entry TESTNAME " p " eval (PUT(PVALUE, PVALUE6.4));
2917        else
2918           entry TESTNAME " p=" eval (PUT(PVALUE, PVALUE6.4));
2919        endif;
2920     %mend;
2921
2922     %macro SingleStratum;
2923        if (PLOTHW=1 AND PLOTEP=0)
2924           bandplot LimitUpper=HW_UCL LimitLower=HW_LCL x=TIME /
2925              displayTail=false modelname="Survival"
2925! fillattrs=GRAPHCONFIDENCE
2926              name="HW" legendlabel=LABELHW;
2927        endif;
2928        if (PLOTHW=0 AND PLOTEP=1)
2929           bandplot LimitUpper=EP_UCL LimitLower=EP_LCL x=TIME /
2930              displayTail=false modelname="Survival"
2930! fillattrs=GRAPHCONFIDENCE
2931              name="EP" legendlabel=LABELEP;
2932        endif;
2933        if (PLOTHW=1 AND PLOTEP=1)
2934           bandplot LimitUpper=HW_UCL LimitLower=HW_LCL x=TIME /
2935              displayTail=false modelname="Survival"
2935! fillattrs=GRAPHDATA1
2936              datatransparency=.55 name="HW" legendlabel=LABELHW;
2937           bandplot LimitUpper=EP_UCL LimitLower=EP_LCL x=TIME /
2938              displayTail=false modelname="Survival"
2938! fillattrs=GRAPHDATA2
2939              datatransparency=.55 name="EP" legendlabel=LABELEP;
2940        endif;
2941        if (PLOTCL=1)
2942           if (PLOTHW=1 OR PLOTEP=1)
2943              bandplot LimitUpper=SDF_UCL LimitLower=SDF_LCL x=TIME /
2944                 displayTail=false modelname="Survival"
2944! display=(outline)
2945                 outlineattrs=GRAPHPREDICTIONLIMITS name="CL"
2945! legendlabel=LABELCL;
2946           else
2947              bandplot LimitUpper=SDF_UCL LimitLower=SDF_LCL x=TIME /
2948                 displayTail=false modelname="Survival"
2948! fillattrs=GRAPHCONFIDENCE
2949                 name="CL" legendlabel=LABELCL;
2950           endif;
2951        endif;
2952
2953        stepplot y=SURVIVAL x=TIME / name="Survival" &tips
2953! legendlabel="Survival"
2954                 &stepopts;
2955
2956        if (PLOTCENSORED=1)
2957           scatterplot y=CENSORED x=TIME / &censored &tiplabel
2958              name="Censored" legendlabel="Censored";
2959        endif;
2960
2961        if (PLOTCL=1 OR PLOTHW=1 OR PLOTEP=1)
2962           discretelegend "Censored" "CL" "HW" "EP" / location=outside
2963              halign=center;
2964        else
2965           if (PLOTCENSORED=1)
2966              discretelegend "Censored" / location=inside
2967                                          autoalign=(topright
2967! bottomleft);
2968           endif;
2969        endif;
2970        %if not &outside %then %do;
2971           if (PLOTATRISK=1)
2972              innermargin / align=bottom;
2973                 axistable x=TATRISK value=ATRISK / &atriskopts;
2974              endinnermargin;
2975           endif;
2976        %end;
2977     %mend;
2978
2979     %macro MultipleStrata;
2980       if (PLOTHW=1)
2981           bandplot LimitUpper=HW_UCL LimitLower=HW_LCL x=TIME /
2981! &bandopts
2982                    datatransparency=Transparency;
2983        endif;
2984        if (PLOTEP=1)
2985           bandplot LimitUpper=EP_UCL LimitLower=EP_LCL x=TIME /
2985! &bandopts
2986                    datatransparency=Transparency;
2987        endif;
2988        if (PLOTCL=1)
2989           if (PLOTHW=1 OR PLOTEP=1)
2990              bandplot LimitUpper=SDF_UCL LimitLower=SDF_LCL x=TIME /
2990! &bandopts
2991                       display=(outline)
2991! outlineattrs=(pattern=ShortDash);
2992           else
2993              bandplot LimitUpper=SDF_UCL LimitLower=SDF_LCL x=TIME /
2993! &bandopts
2994                       datatransparency=Transparency;
2995           endif;
2996        endif;
2997
2998        stepplot y=SURVIVAL x=TIME / &groups name="Survival" &tips
2998! &stepopts;
2999
3000        if (PLOTCENSORED=1)
3001           scatterplot y=CENSORED x=TIME / &groups &tiplabel &censored;
3002        endif;
3003
3004        %if not &outside %then %do;
3005           if (PLOTATRISK=1)
3006              innermargin / align=bottom;
3007                 axistable x=TATRISK value=ATRISK / &atriskopts
3007! &classopts;
3008              endinnermargin;
3009           endif;
3010        %end;
3011
3012        %if %nrbquote(&legendopts) ne %then %do;
3013           DiscreteLegend "Survival" / &legendopts;
3014        %end;
3015
3016        %if %nrbquote(&insetopts) ne %then %do;
3017           if (PLOTCENSORED=1)
3018              if (PLOTTEST=1)
3019                 layout gridded / rows=2 &insetopts;
3020                    entry &censorstr;
3021                    %pValue
3022                 endlayout;
3023              else
3024                 layout gridded / rows=1 &insetopts;
3025                    entry &censorstr;
3026                 endlayout;
3027              endif;
3028           else
3029              if (PLOTTEST=1)
3030                 layout gridded / rows=1 &insetopts;
3031                    %pValue
3032                 endlayout;
3033              endif;
3034           endif;
3035           %end;
3036
3037     %mend;
3038
3039     %macro SurvTabHeader(multiple);
3040        %if &multiple %then %do; entry ""; %end;
3041        entry "";
3042        entry "";
3043        entry "";
3044        entry &r "Median";
3045        entry "";
3046        entry "";
3047
3048        %if &multiple %then %do; entry ""; %end;
3049        entry &r "Subjects";
3050        entry &r "Event";
3051        entry &r "Censored";
3052        entry &r "Survival";
3053        entry &r PctMedianConfid;
3054        entry halign=left  "CL";
3055     %mend;
3056
3057     %macro SurvivalTable;
3058        %local fmt r i t;
3059        %let fmt = bestd6.;
3060        %let r = halign = right;
3061        columnheaders;
3062           layout overlay / pad=(top=5);
3063              if(NSTRATA=1)
3064                 layout gridded / columns=6 border=TRUE;
3065                    dynamic PctMedianConfid NObs NEvent Median
3066                            LowerMedian UpperMedian;
3067                    %SurvTabHeader(0)
3068                    entry &r NObs;
3069                    entry &r NEvent;
3070                    entry &r eval(NObs-NEvent);
3071                    entry &r eval(put(Median,&fmt));
3072                    entry &r eval(put(LowerMedian,&fmt));
3073                    entry &r eval(put(UpperMedian,&fmt));
3074                 endlayout;
3075              else
3076                 layout gridded / columns=7 border=TRUE;
3077                    dynamic PctMedianConfid;
3078                    %SurvTabHeader(1)
3079                    %do i = 1 %to 10;
3080                       %let t = / textattrs=GraphData&i;
3081                       dynamic StrVal&i NObs&i NEvent&i Median&i
3082                               LowerMedian&i UpperMedian&i;
3083                       if (&i <= nstrata)
3084                          entry &r StrVal&i &t;
3085                          entry &r NObs&i &t;
3086                          entry &r NEvent&i &t;
3087                          entry &r eval(NObs&i-NEvent&i) &t;
3088                          entry &r eval(put(Median&i,&fmt)) &t;
3089                          entry &r eval(put(LowerMedian&i,&fmt)) &t;
3090                          entry &r eval(put(UpperMedian&i,&fmt)) &t;
3091                       endif;
3092                    %end;
3093                 endlayout;
3094              endif;
3095           endlayout;
3096        endcolumnheaders;
3097     %mend;
3098
3099     %macro SurvivalSummaryTable;
3100        %macro AtRiskLatticeStart;
3101           layout lattice / columndatarange=union rowgutter=10
3102              rows=%if &outside %then 2 rowweights=ROWWEIGHTS;
3103                   %else              1;;
3104           %if &outside %then %do; cell; %end;
3105        %mend;
3106
3107        %macro AtRiskLatticeEnd(useclassopts);
3108           %if &outside %then %do;
3109              endcell;
3110              cell;
3111                 layout overlay / walldisplay=none
3111! xaxisopts=(display=none);
3112                    axistable x=TATRISK value=ATRISK / &atriskopts
3113                              %if &useclassopts ne %then &classopts;;
3114                 endlayout;
3115              endcell;
3116           %end;
3117           %SurvivalTable
3118           endlayout;
3119        %mend;
3120     %mend;
3121
3122     %macro AtRiskLatticeStart;
3123        %if &outside %then %do;
3124           layout lattice / rows=2 rowweights=ROWWEIGHTS
3125                            columndatarange=union rowgutter=10;
3126           cell;
3127        %end;
3128     %mend;
3129
3130     %macro AtRiskLatticeEnd(useclassopts);
3131        %if &outside %then %do;
3132           endcell;
3133           cell;
3134              layout overlay / walldisplay=none xaxisopts=(display=none)
3134! ;
3135                 axistable x=TATRISK value=ATRISK / &atriskopts
3136                           %if &useclassopts ne %then &classopts;;
3137              endlayout;
3138           endcell;
3139        endlayout;
3140        %end;
3141     %mend;
3142
3143  %CompileSurvivalTemplates
3144  %mend;
3145
3146
3147
3148  /*
3149
3150  proc template;
3151     delete Stat.Lifetest.Graphics.ProductLimitSurvival  /
3152            store=sasuser.templat;
3153     delete Stat.Lifetest.Graphics.ProductLimitSurvival2 /
3154            store=sasuser.templat;
3155  run;
3156
3157  proc template;
3158     delete Stat.Lifetest.Graphics.ProductLimitFailure  /
3159            store=sasuser.templat;
3160     delete Stat.Lifetest.Graphics.ProductLimitFailure2 /
3161            store=sasuser.templat;
3162  run;
3163  */
3164
3165
3166  **********************************************************************
3166! ***********************;
3167  * PP all days ;
3168  **********************************************************************
3168! ***********************;
3169
3170
3171  filename out1 "&dir&client&project\output\gm_Mortality_Day90
3171! 2019-11-16.rtf";
ERROR: At least one file associated with fileref OUT1 is still in use.
ERROR: Error in the FILENAME statement.
3172
3173
3174  title3 'gm_Mortality_Day90.sas';
3175  ods rtf file=out1;
NOTE: Writing RTF Body file: OUT1
3176
3177  options pageno=1;
3178
3179
3180  %ProvideSurvivalMacros
NOTE: Overwriting existing template/link:
      Stat.Lifetest.Graphics.ProductLimitFailure
NOTE: STATGRAPH 'Stat.Lifetest.Graphics.ProductLimitFailure' has been saved
      to: SASUSER.TEMPLAT
NOTE: Overwriting existing template/link:
      Stat.Lifetest.Graphics.ProductLimitFailure2
NOTE: STATGRAPH 'Stat.Lifetest.Graphics.ProductLimitFailure2' has been
      saved to: SASUSER.TEMPLAT
NOTE: PROCEDURE TEMPLATE used (Total process time):
      real time           0.01 seconds
      cpu time            0.01 seconds

3181
3182     %let yOptions   = label="Survival Probability"
3182! shortlabel="Survival"
3183                       linearopts=(viewmin=.75 viewmax=1
3184                                   tickvaluelist=(.7 .75 .8 .85 .9 .95
3184! 1));
3185
3186
3187    * %let yOptions   = label="Cumulative Mortality"
3187! shortlabel="Mortality"
3188                       linearopts=(viewmin=0 viewmax=1
3189                                   tickvaluelist=(0 .2 .4 .6 .8 1.0));
3190
3191
3192   %let xOptions   = shortlabel=XNAME offsetmin=.05
3193                       linearopts=(viewmax=MAXTIME tickvaluelist=(0 7 14
3193!  21 28 35 42 49 56 63 70 77 84 91)
3194                                   tickvaluefitpolicy=XTICKVALFITPOL);
3195
3196  %let TitleText2 = "Kaplan-Meier Plot in Per Protocol Analysis Set";
3197  %let LegendOpts = title="+ Censored"
3198                    location=inside autoalign=(Bottom);
3199  *%let InsetOpts  = ;
3200
3201
3202  %macro StmtsBottom;
3203     dynamic %do i = 1 %to 3; StrVal&i NObs&i NEvent&i %end;;
3204     layout gridded / columns=3 border=TRUE autoalign=(Top);
3205        entry ""; entry "Event"; entry "Total";
3206        %do i = 1 %to 3;
3207           %let t = / textattrs=GraphData&i;
3208           entry halign=right Strval&i &t; entry NEvent&i &t; entry
3208! NObs&i &t;
3209        %end;
3210     endlayout;
3211  %mend;
3212
3213  %let GraphOpts = DesignHeight=DefaultDesignWidth;
3214
3215
3216  %macro pValue;
3217     if (PVALUE < .0001)
3218        entry "Log Rank p "   eval (PUT(PVALUE, PVALUE6.4));
3219     else
3220        entry "Log Rank p = " eval (PUT(PVALUE, PVALUE6.4));
3221     endif;
3222  %mend;
3223
3224
3225  *%SurvivalSummaryTable;
3226
3227
3228  %CompileSurvivalTemplates
NOTE: Overwriting existing template/link:
      Stat.Lifetest.Graphics.ProductLimitFailure
NOTE: STATGRAPH 'Stat.Lifetest.Graphics.ProductLimitFailure' has been saved
      to: SASUSER.TEMPLAT
NOTE: Overwriting existing template/link:
      Stat.Lifetest.Graphics.ProductLimitFailure2
NOTE: STATGRAPH 'Stat.Lifetest.Graphics.ProductLimitFailure2' has been
      saved to: SASUSER.TEMPLAT
NOTE: PROCEDURE TEMPLATE used (Total process time):
      real time           0.01 seconds
      cpu time            0.00 seconds

3229
3230
3231  proc format;
3232   value group 1='Relticimod' 2='Placebo';
NOTE: Format GROUP is already on the library WORK.FORMATS.
NOTE: Format GROUP has been output.
3233   run;
NOTE: PROCEDURE FORMAT used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds

3234
3235
3236
3237  title4 'Kaplan-Meier Survival to Day 90 in Per Protocol Analysis Set';
3238  proc lifetest data=modPP  rmst plots= survival ( test atrisk = 1 to 90
3238!  by 7 /*cb=hw*/) timelist = 1,2,3,4,5,6,7,14,21,28,60,90 ;
3239  time days_mort90*censor_mort90(1);
3240  strata group /order=internal;
3241  label group='Dose Group';
3242  label days_mort90='Days to Death or Censor';
3243  format group group.;
3244  run;
NOTE: The LOGLOG transform is used to compute the confidence limits for the
      quartiles of the survivor distribution. To suppress using this
      transform, specify CONFTYPE=LINEAR in the PROC LIFETEST statement.
NOTE: PROCEDURE LIFETEST used (Total process time):
      real time           0.61 seconds
      cpu time            0.32 seconds

3245
3246  /*Need to first edit SAS provided macro changing
3246! ProductLimitSurvival to ProductLimitFailure*/
3247
3248  %ProvideSurvivalMacros
NOTE: Overwriting existing template/link:
      Stat.Lifetest.Graphics.ProductLimitFailure
NOTE: STATGRAPH 'Stat.Lifetest.Graphics.ProductLimitFailure'
      has been saved to: SASUSER.TEMPLAT
NOTE: Overwriting existing template/link:
      Stat.Lifetest.Graphics.ProductLimitFailure2
NOTE: STATGRAPH 'Stat.Lifetest.Graphics.ProductLimitFailure2'
      has been saved to: SASUSER.TEMPLAT
NOTE: PROCEDURE TEMPLATE used (Total process time):
      real time           0.02 seconds
      cpu time            0.01 seconds

3249
3250     *%let yOptions   = label="Survival Probability"
3250! shortlabel="Survival"
3251                       linearopts=(viewmin=.75 viewmax=1
3252                                   tickvaluelist=(.7 .75 .8
3252! .85 .9 .95 1));
3253
3254
3255     %let yOptions   = label="Cumulative Mortality"
3255! shortlabel="Mortality"
3256                       linearopts=(viewmin=0 viewmax=0.25
3257                                   tickvaluelist=(0 0.05
3257! 0.10 0.15 0.20 0.25));
3258
3259
3260   %let xOptions   = shortlabel=XNAME offsetmin=.05
3261                       linearopts=(viewmax=MAXTIME
3261! tickvaluelist=(0 7 14 21 28 35 42 49 56 63 70 77 84 91)
3262                                   tickvaluefitpolicy=XTICKV
3262! ALFITPOL);
3263
3264  %let TitleText2 = "Kaplan-Meier Plot in Per Protocol
3264! Analysis Set";
3265  %let LegendOpts = title="+ Censored"
3266                    location=inside autoalign=(Bottom);
3267  *%let InsetOpts  = ;
3268
3269
3270  %macro StmtsBottom;
3271     dynamic %do i = 1 %to 3; StrVal&i NObs&i NEvent&i %end;
3271! ;
3272     layout gridded / columns=3 border=TRUE autoalign=(Top);
3273        entry ""; entry "Event"; entry "Total";
3274        %do i = 1 %to 3;
3275           %let t = / textattrs=GraphData&i;
3276           entry halign=right Strval&i &t; entry NEvent&i &t
3276! ; entry NObs&i &t;
3277        %end;
3278     endlayout;
3279  %mend;
3280
3281  %let GraphOpts = DesignHeight=DefaultDesignWidth;
3282
3283
3284  %macro pValue;
3285     if (PVALUE < .0001)
3286        entry "Log Rank p "   eval (PUT(PVALUE, PVALUE6.4));
3287     else
3288        entry "Log Rank p = " eval (PUT(PVALUE, PVALUE6.4));
3289     endif;
3290  %mend;
3291
3292
3293  *%SurvivalSummaryTable;
3294
3295
3296  %CompileSurvivalTemplates
NOTE: Overwriting existing template/link:
      Stat.Lifetest.Graphics.ProductLimitFailure
NOTE: STATGRAPH 'Stat.Lifetest.Graphics.ProductLimitFailure'
      has been saved to: SASUSER.TEMPLAT
NOTE: Overwriting existing template/link:
      Stat.Lifetest.Graphics.ProductLimitFailure2
NOTE: STATGRAPH 'Stat.Lifetest.Graphics.ProductLimitFailure2'
      has been saved to: SASUSER.TEMPLAT
NOTE: PROCEDURE TEMPLATE used (Total process time):
      real time           0.01 seconds
      cpu time            0.01 seconds

3297
3298
3299
3300  title4 'Kaplan-Meier Cumulative Failure to Day 90 in Per
3300! Protocol Analysis Set';
3301  proc lifetest data=modPP  rmst plots= survival ( failure
3301! test atrisk = 1 to 90 by 7 /*cb=hw*/) timelist =
3301! 1,2,3,4,5,6,7,14,21,28,60,90 ;
3302  time days_mort90*censor_mort90(1);
3303  strata group /order=internal;
3304  label group='Dose Group';
3305  label days_mort90='Days to Death or Censor';
3306  format group group.;
3307  run;
NOTE: The LOGLOG transform is used to compute the confidence
      limits for the quartiles of the survivor distribution. To
      suppress using this transform, specify CONFTYPE=LINEAR in
      the PROC LIFETEST statement.
NOTE: PROCEDURE LIFETEST used (Total process time):
      real time           0.70 seconds
      cpu time            0.21 seconds

3308
3309  ods rtf close;
greg_maislin
Fluorite | Level 6

code from my question. Thanks! Greg

 

title3 'gm_Mortality_Day90.sas';
proc format;
 value $suc 1='aSuccess' 2='bFailure';
 value bmi_cat 1='a<30' 2='b30-40' 3='c>40';
 value yn10fmt 1='aYes' 0='bNo';
 value $yn10fmt 1='aYes' 0='bNo';
 value grp 1='aReltec.' 2='bPlacebo';
 value censor 1='bNo Death' 0='aDeath';
 run;
 
%macro timevarprint();
data hr2;
 set hr;
 HR=exp(ESTIMATE);
 lb=exp(estimate-1.96*STDERR);
 ub=exp(estimate+1.96*STDERR);
 run;
title6 "Hazard Ratio Post Day 14";
proc print data=hr2;
run;
%mend;
 
 
data at;
 set sasdat.effshort;
 if group4=1 ;
  
 censor_mort90 = censor; drop censor;
 days_mort90 = ttime ; drop ttime;
 if days_mort90>90 then do days_mort90=90 ;  /*there is an 852*/
 censor_mort90=1;
 end;
 label
 nfail='Renal fail'
 rfail='Resp. fail'
 ;
 if bmilt30=1 then bmi_cat=1;
 if bmige40=1 then bmi_cat=3;
 if bmi30lt40=1 then bmi_cat=2;
 format bmi_cat bmi_cat. ;
 if site in ("01 Limoges", "03 Creteil", "05 Lille", "06 Lyon", "07 Nancy") then french=1;
 else french=0;
 format french bmige40 bmilt30 CCGANG CKD nfail rfail cfail /*fgang*/ ccgang ccnfasc aki_st3 aki_stg0 bmige40 yn10fmt.
 group grp. nicce $suc. censor_mort14 censor_mort28 censor_mort90 censor. fgang $yn10fmt. eff4 eff5 $suc.;

 if group=1 then control=0;
 if group=2 then control=1;
 run;
 

data modpp;
 set at;
 if modppexc ne 1;
 run;
 

/****************************************************************/
/*          S A S   S A M P L E   L I B R A R Y                 */
/*                                                              */
/*    NAME: TEMPLFT                                             */
/*   TITLE: PROC LIFETEST Template                              */
/* PRODUCT: STAT                                                */
/*  SYSTEM: ALL                                                 */
/*    KEYS: graphics, ods, survival analysis, Kaplan-Meier      */
/*   PROCS:                                                     */
/*    DATA:                                                     */
/*                                                              */
/* SUPPORT: saswfk                UPDATE: July 25, 2013         */
/*     REF: ods graphics                                        */
/*    MISC:                                                     */
/*   NOTES: This sample provides templates for the PROC         */
/*          LIFETEST survival plot that are modular and         */
/*          easier to modify than the default templates.        */
/****************************************************************/
%macro ProvideSurvivalMacros;
   %global atriskopts bandopts censored censorstr classopts
           graphopts groups insetopts legendopts ntitles stepopts tiplabel
           tips titletext0 titletext1 titletext2 xoptions yoptions;
   %let TitleText0 = METHOD " Survival Estimate";
   %let TitleText1 = &titletext0 " for " STRATUMID;
   %let TitleText2 = &titletext0 "s";         /* plural: Survival Estimates */
   %let nTitles    = 2;

   %let yOptions   = label="Survival Probability" shortlabel="Survival"
                     linearopts=(viewmin=0 viewmax=1
                                 tickvaluelist=(0 .2 .4 .6 .8 1.0));
 
   %let xOptions   = shortlabel=XNAME offsetmin=.05
                     linearopts=(viewmax=MAXTIME tickvaluelist=XTICKVALS
                                 tickvaluefitpolicy=XTICKVALFITPOL);
   %let Tips       = rolename=(_tip1= ATRISK _tip2=EVENT)
                     tiplabel=(_tip1="Number at Risk" _tip2="Observed Events")
                     tip=(x y _tip1 _tip2);
   %let TipLabel   = tiplabel=(y="Survival Probability");
   %let StepOpts   = ;
   %let Groups     = group=STRATUM index=STRATUMNUM;
   %let BandOpts   = displayTail=false &groups modelname="Survival";
   %let InsetOpts  = autoalign=(TOPRIGHT BOTTOMLEFT TOP BOTTOM)
                     border=true BackgroundColor=GraphWalls:Color Opaque=true;
   %let LegendOpts = title=GROUPNAME location=outside;
   %let AtRiskOpts = display=(label) valueattrs=(size=7pt);
   %let ClassOpts  = class=CLASSATRISK colorgroup=CLASSATRISK;
   %let Censored   = markerattrs=(symbol=plus);
   %let CensorStr  = "+ Censored";
   %let GraphOpts  = ;
   %macro StmtsBeginGraph; %mend;
   %macro StmtsTop;        %mend;
   %macro StmtsBottom;     %mend;
   %macro CompileSurvivalTemplates;
      %local outside;
      proc template;
         %do outside = 0 %to 1;
            define statgraph
              
      Stat.Lifetest.Graphics.ProductLimitFailure%scan(2,2-&outside);   /*HERE IS CHANGE: ProductLimitSurvival to ProductLimitFailure*/
               dynamic NStrata xName plotAtRisk
                  %if %nrbquote(&censored) ne %then plotCensored;
                  plotCL plotHW plotEP labelCL labelHW labelEP maxTime xtickVals
                  xtickValFitPol rowWeights method StratumID classAtRisk
                  plotTest GroupName Transparency SecondTitle TestName pValue
                  _byline_ _bytitle_ _byfootnote_;
               BeginGraph %if %nrbquote(&graphopts) ne %then / &graphopts;;
               if (NSTRATA=1)
                  %if &ntitles %then %do;
                     if (EXISTS(STRATUMID)) entrytitle &titletext1;
                     else                   entrytitle &titletext0;
                     endif;
                  %end;
                  %if &ntitles gt 1 %then %do;
                     %if not &outside %then if (PLOTATRISK=1);
                        entrytitle "With Number of Subjects at Risk" /
                                   textattrs=GRAPHVALUETEXT;
                     %if not &outside %then %do; endif; %end;
                  %end;
                  %StmtsBeginGraph
                  %AtRiskLatticeStart
                  layout overlay / xaxisopts=(&xoptions) yaxisopts=(&yoptions);
                     %StmtsTop
                     %SingleStratum
                     %StmtsBottom
                  endlayout;
                  %AtRiskLatticeEnd
               else
                  %if &ntitles %then %do; entrytitle &titletext2; %end;
                  %if &ntitles gt 1 %then %do;
                     if (EXISTS(SECONDTITLE))
                        entrytitle SECONDTITLE / textattrs=GRAPHVALUETEXT;
                     endif;
                  %end;
                  %StmtsBeginGraph
                  %AtRiskLatticeStart
                  layout overlay / xaxisopts=(&xoptions) yaxisopts=(&yoptions);
                     %StmtsTop
                     %MultipleStrata
                     %StmtsBottom
                  endlayout;
                  %AtRiskLatticeEnd(class)
               endif;
               if (_BYTITLE_) entrytitle _BYLINE_ / textattrs=GRAPHVALUETEXT;
               else if (_BYFOOTNOTE_) entryfootnote halign=left _BYLINE_; endif;
               endif;
               EndGraph;
            end;
         %end;
      run;
   %mend;
   %macro pValue;
      if (PVALUE < .0001)
         entry TESTNAME " p " eval (PUT(PVALUE, PVALUE6.4));
      else
         entry TESTNAME " p=" eval (PUT(PVALUE, PVALUE6.4));
      endif;
   %mend;
   %macro SingleStratum;
      if (PLOTHW=1 AND PLOTEP=0)
         bandplot LimitUpper=HW_UCL LimitLower=HW_LCL x=TIME /
            displayTail=false modelname="Survival" fillattrs=GRAPHCONFIDENCE
            name="HW" legendlabel=LABELHW;
      endif;
      if (PLOTHW=0 AND PLOTEP=1)
         bandplot LimitUpper=EP_UCL LimitLower=EP_LCL x=TIME /
            displayTail=false modelname="Survival" fillattrs=GRAPHCONFIDENCE
            name="EP" legendlabel=LABELEP;
      endif;
      if (PLOTHW=1 AND PLOTEP=1)
         bandplot LimitUpper=HW_UCL LimitLower=HW_LCL x=TIME /
            displayTail=false modelname="Survival" fillattrs=GRAPHDATA1
            datatransparency=.55 name="HW" legendlabel=LABELHW;
         bandplot LimitUpper=EP_UCL LimitLower=EP_LCL x=TIME /
            displayTail=false modelname="Survival" fillattrs=GRAPHDATA2
            datatransparency=.55 name="EP" legendlabel=LABELEP;
      endif;
      if (PLOTCL=1)
         if (PLOTHW=1 OR PLOTEP=1)
            bandplot LimitUpper=SDF_UCL LimitLower=SDF_LCL x=TIME /
               displayTail=false modelname="Survival" display=(outline)
               outlineattrs=GRAPHPREDICTIONLIMITS name="CL" legendlabel=LABELCL;
         else
            bandplot LimitUpper=SDF_UCL LimitLower=SDF_LCL x=TIME /
               displayTail=false modelname="Survival" fillattrs=GRAPHCONFIDENCE
               name="CL" legendlabel=LABELCL;
         endif;
      endif;
      stepplot y=SURVIVAL x=TIME / name="Survival" &tips legendlabel="Survival"
               &stepopts;
      if (PLOTCENSORED=1)
         scatterplot y=CENSORED x=TIME / &censored &tiplabel
            name="Censored" legendlabel="Censored";
      endif;
      if (PLOTCL=1 OR PLOTHW=1 OR PLOTEP=1)
         discretelegend "Censored" "CL" "HW" "EP" / location=outside
            halign=center;
      else
         if (PLOTCENSORED=1)
            discretelegend "Censored" / location=inside
                                        autoalign=(topright bottomleft);
         endif;
      endif;
      %if not &outside %then %do;
         if (PLOTATRISK=1)
            innermargin / align=bottom;
               axistable x=TATRISK value=ATRISK / &atriskopts;
            endinnermargin;
         endif;
      %end;
   %mend;
   %macro MultipleStrata;
     if (PLOTHW=1)
         bandplot LimitUpper=HW_UCL LimitLower=HW_LCL x=TIME / &bandopts
                  datatransparency=Transparency;
      endif;
      if (PLOTEP=1)
         bandplot LimitUpper=EP_UCL LimitLower=EP_LCL x=TIME / &bandopts
                  datatransparency=Transparency;
      endif;
      if (PLOTCL=1)
         if (PLOTHW=1 OR PLOTEP=1)
            bandplot LimitUpper=SDF_UCL LimitLower=SDF_LCL x=TIME / &bandopts
                     display=(outline) outlineattrs=(pattern=ShortDash);
         else
            bandplot LimitUpper=SDF_UCL LimitLower=SDF_LCL x=TIME / &bandopts
                     datatransparency=Transparency;
         endif;
      endif;
      stepplot y=SURVIVAL x=TIME / &groups name="Survival" &tips &stepopts;
      if (PLOTCENSORED=1)
         scatterplot y=CENSORED x=TIME / &groups &tiplabel &censored;
      endif;
      %if not &outside %then %do;
         if (PLOTATRISK=1)
            innermargin / align=bottom;
               axistable x=TATRISK value=ATRISK / &atriskopts &classopts;
            endinnermargin;
         endif;
      %end;
      %if %nrbquote(&legendopts) ne %then %do;
         DiscreteLegend "Survival" / &legendopts;
      %end;
      %if %nrbquote(&insetopts) ne %then %do;
         if (PLOTCENSORED=1)
            if (PLOTTEST=1)
               layout gridded / rows=2 &insetopts;
                  entry &censorstr;
                  %pValue
               endlayout;
            else
               layout gridded / rows=1 &insetopts;
                  entry &censorstr;
               endlayout;
            endif;
         else
            if (PLOTTEST=1)
               layout gridded / rows=1 &insetopts;
                  %pValue
               endlayout;
            endif;
         endif;
         %end;
   %mend;
   %macro SurvTabHeader(multiple);
      %if &multiple %then %do; entry ""; %end;
      entry "";
      entry "";
      entry "";
      entry &r "Median";
      entry "";
      entry "";
      %if &multiple %then %do; entry ""; %end;
      entry &r "Subjects";
      entry &r "Event";
      entry &r "Censored";
      entry &r "Survival";
      entry &r PctMedianConfid;
      entry halign=left  "CL";
   %mend;
   %macro SurvivalTable;
      %local fmt r i t;
      %let fmt = bestd6.;
      %let r = halign = right;
      columnheaders;
         layout overlay / pad=(top=5);
            if(NSTRATA=1)
               layout gridded / columns=6 border=TRUE;
                  dynamic PctMedianConfid NObs NEvent Median
                          LowerMedian UpperMedian;
                  %SurvTabHeader(0)
                  entry &r NObs;
                  entry &r NEvent;
                  entry &r eval(NObs-NEvent);
                  entry &r eval(put(Median,&fmt));
                  entry &r eval(put(LowerMedian,&fmt));
                  entry &r eval(put(UpperMedian,&fmt));
               endlayout;
            else
               layout gridded / columns=7 border=TRUE;
                  dynamic PctMedianConfid;
                  %SurvTabHeader(1)
                  %do i = 1 %to 10;
                     %let t = / textattrs=GraphData&i;
                     dynamic StrVal&i NObs&i NEvent&i Median&i
                             LowerMedian&i UpperMedian&i;
                     if (&i <= nstrata)
                        entry &r StrVal&i &t;
                        entry &r NObs&i &t;
                        entry &r NEvent&i &t;
                        entry &r eval(NObs&i-NEvent&i) &t;
                        entry &r eval(put(Median&i,&fmt)) &t;
                        entry &r eval(put(LowerMedian&i,&fmt)) &t;
                        entry &r eval(put(UpperMedian&i,&fmt)) &t;
                     endif;
                  %end;
               endlayout;
            endif;
         endlayout;
      endcolumnheaders;
   %mend;
   %macro SurvivalSummaryTable;
      %macro AtRiskLatticeStart;
         layout lattice / columndatarange=union rowgutter=10
            rows=%if &outside %then 2 rowweights=ROWWEIGHTS;
                 %else              1;;
         %if &outside %then %do; cell; %end;
      %mend;
      %macro AtRiskLatticeEnd(useclassopts);
         %if &outside %then %do;
            endcell;
            cell;
               layout overlay / walldisplay=none xaxisopts=(display=none);
                  axistable x=TATRISK value=ATRISK / &atriskopts
                            %if &useclassopts ne %then &classopts;;
               endlayout;
            endcell;
         %end;
         %SurvivalTable
         endlayout;
      %mend;
   %mend;
   %macro AtRiskLatticeStart;
      %if &outside %then %do;
         layout lattice / rows=2 rowweights=ROWWEIGHTS
                          columndatarange=union rowgutter=10;
         cell;
      %end;
   %mend;
   %macro AtRiskLatticeEnd(useclassopts);
      %if &outside %then %do;
         endcell;
         cell;
            layout overlay / walldisplay=none xaxisopts=(display=none);
               axistable x=TATRISK value=ATRISK / &atriskopts
                         %if &useclassopts ne %then &classopts;;
            endlayout;
         endcell;
      endlayout;
      %end;
   %mend;
%CompileSurvivalTemplates
%mend;
 
/*
proc template;
   delete Stat.Lifetest.Graphics.ProductLimitSurvival  /
          store=sasuser.templat;
   delete Stat.Lifetest.Graphics.ProductLimitSurvival2 /
          store=sasuser.templat;
run;
proc template;
   delete Stat.Lifetest.Graphics.ProductLimitFailure  /
          store=sasuser.templat;
   delete Stat.Lifetest.Graphics.ProductLimitFailure2 /
          store=sasuser.templat;
run;
*/

*********************************************************************************************;
* PP all days ;
*********************************************************************************************;

filename out1 "&dir&client&project\output\gm_Mortality_Day90 2019-11-16.rtf";

title3 'gm_Mortality_Day90.sas';
ods rtf file=out1;
options pageno=1;

%ProvideSurvivalMacros
   %let yOptions   = label="Survival Probability" shortlabel="Survival"
                     linearopts=(viewmin=.75 viewmax=1
                                 tickvaluelist=(.7 .75 .8 .85 .9 .95 1));

  * %let yOptions   = label="Cumulative Mortality" shortlabel="Mortality"
                     linearopts=(viewmin=0 viewmax=1
                                 tickvaluelist=(0 .2 .4 .6 .8 1.0));

 %let xOptions   = shortlabel=XNAME offsetmin=.05
                     linearopts=(viewmax=MAXTIME tickvaluelist=(0 7 14 21 28 35 42 49 56 63 70 77 84 91)
                                 tickvaluefitpolicy=XTICKVALFITPOL);
%let TitleText2 = "Kaplan-Meier Plot in Per Protocol Analysis Set";
%let LegendOpts = title="+ Censored"
                  location=inside autoalign=(Bottom);
*%let InsetOpts  = ;

%macro StmtsBottom;
   dynamic %do i = 1 %to 3; StrVal&i NObs&i NEvent&i %end;;
   layout gridded / columns=3 border=TRUE autoalign=(Top);
      entry ""; entry "Event"; entry "Total";
      %do i = 1 %to 3;
         %let t = / textattrs=GraphData&i;
         entry halign=right Strval&i &t; entry NEvent&i &t; entry NObs&i &t;
      %end;
   endlayout;
%mend;
%let GraphOpts = DesignHeight=DefaultDesignWidth;

%macro pValue;
   if (PVALUE < .0001)
      entry "Log Rank p "   eval (PUT(PVALUE, PVALUE6.4));
   else
      entry "Log Rank p = " eval (PUT(PVALUE, PVALUE6.4));
   endif;
%mend;

*%SurvivalSummaryTable;

%CompileSurvivalTemplates

proc format;
 value group 1='Relticimod' 2='Placebo';
 run;
 
title4 'Kaplan-Meier Survival to Day 90 in Per Protocol Analysis Set';
proc lifetest data=modPP  rmst plots= survival ( test atrisk = 1 to 90 by 7 /*cb=hw*/) timelist = 1,2,3,4,5,6,7,14,21,28,60,90 ;
time days_mort90*censor_mort90(1);
strata group /order=internal;
label group='Dose Group';
label days_mort90='Days to Death or Censor';
format group group.;
run;
/*Need to first edit SAS provided macro changing ProductLimitSurvival to ProductLimitFailure*/
%ProvideSurvivalMacros
   *%let yOptions   = label="Survival Probability" shortlabel="Survival"
                     linearopts=(viewmin=.75 viewmax=1
                                 tickvaluelist=(.7 .75 .8 .85 .9 .95 1));

   %let yOptions   = label="Cumulative Mortality" shortlabel="Mortality"
                     linearopts=(viewmin=0 viewmax=0.25
                                 tickvaluelist=(0 0.05 0.10 0.15 0.20 0.25));

 %let xOptions   = shortlabel=XNAME offsetmin=.05
                     linearopts=(viewmax=MAXTIME tickvaluelist=(0 7 14 21 28 35 42 49 56 63 70 77 84 91)
                                 tickvaluefitpolicy=XTICKVALFITPOL);
%let TitleText2 = "Kaplan-Meier Plot in Per Protocol Analysis Set";
%let LegendOpts = title="+ Censored"
                  location=inside autoalign=(Bottom);
*%let InsetOpts  = ;

%macro StmtsBottom;
   dynamic %do i = 1 %to 3; StrVal&i NObs&i NEvent&i %end;;
   layout gridded / columns=3 border=TRUE autoalign=(Top);
      entry ""; entry "Event"; entry "Total";
      %do i = 1 %to 3;
         %let t = / textattrs=GraphData&i;
         entry halign=right Strval&i &t; entry NEvent&i &t; entry NObs&i &t;
      %end;
   endlayout;
%mend;
%let GraphOpts = DesignHeight=DefaultDesignWidth;

%macro pValue;
   if (PVALUE < .0001)
      entry "Log Rank p "   eval (PUT(PVALUE, PVALUE6.4));
   else
      entry "Log Rank p = " eval (PUT(PVALUE, PVALUE6.4));
   endif;
%mend;

*%SurvivalSummaryTable;

%CompileSurvivalTemplates
 
title4 'Kaplan-Meier Cumulative Failure to Day 90 in Per Protocol Analysis Set';
proc lifetest data=modPP  rmst plots= survival ( failure test atrisk = 1 to 90 by 7 /*cb=hw*/) timelist = 1,2,3,4,5,6,7,14,21,28,60,90 ;
time days_mort90*censor_mort90(1);
strata group /order=internal;
label group='Dose Group';
label days_mort90='Days to Death or Censor';
format group group.;
run;
 
ods rtf close;  
Reeza
Super User
Ok...I'll have time to take a deeper look tonight but it seems like your %MEND are not in the correct place. It would help if you formatted the code (autoformat is fine) and posted it in a code block so it's legible. It's hard to follow long blobs of text sometimes when there's no formatting.
greg_maislin
Fluorite | Level 6

thank you.  Yes, I saw that.  I replied via e-mail and checked format.  It was horrible, so a copied and pasted from program window.  Much easier to read. 

greg_maislin
Fluorite | Level 6

So this is what I have discovered.  I can create a failure plot using plots=survival(failure).   But whenever I attempt to edit the template

Stat.Lifetest.Graphics.ProductLimitFailure such as the y and x axis, titles, and labels, the change I desire are implemented, but  a survival and not a failure plot is produced.   I thought the K-M plots were missing because I set the y-axis to go from 0 to 0.3 as appropriate for failures, but the survival plot goes from 0.7 to 1 and so there was nothing to plot.  Once I change the y-axis to 0.7 to 1.0 I see all my other edits to the failure plot such as labels, etc, but a survival and not a failure plot is printed.  I'm beginning to believe this is a bug in my version of SAS. 

 

I even tried a different approach. Even though I am editing Stat.Lifetest.Graphics.ProductLimitFailure, the subsequent call to proc lifetest produces a survival plot and not a failure plot even though I specified plots=survival(failure).   If I delete the modified template, then plots=survival(failure) does produce a failure plot.   So I am stuck not being able to edit KM failure plots in PROC LIFETEST.  

 

 

proc template;

define statgraph Stat.Lifetest.Graphics.ProductLimitFailure;

dynamic NStrata xName plotAtRisk plotCensored plotCL plotHW plotEP

 

labelCL labelHW labelEP maxTime xtickVals xtickValFitPol rowWeights

method StratumID classAtRisk plotTest GroupName Transparency

SecondTitle TestName pValue _byline_ _bytitle_ _byfootnote_ StrVal1

NObs1 NEvent1 StrVal2 NObs2 NEvent2 StrVal3 NObs3 NEvent3;

BeginGraph / DesignHeight=DefaultDesignWidth;

if (NSTRATA=1)

 

if (EXISTS(STRATUMID))

entrytitle METHOD " Survival Estimate" " for " STRATUMID;

else

entrytitle METHOD " Survival Estimate";

endif;

if (PLOTATRISK=1)

entrytitle "With Number of Subjects at Risk" / textattrs=

 

GRAPHVALUETEXT;

endif;

layout overlay / xaxisopts=(shortlabel=XNAME offsetmin=.05

linearopts=(viewmax=MAXTIME tickvaluelist=(0 7 14 21 28 35 42

49 56 63 70 77 84 91) tickvaluefitpolicy=XTICKVALFITPOL))

yaxisopts=(label="Cumulative Mortality" shortlabel="Mortality"

linearopts=(viewmin=0 viewmax=1 tickvaluelist=(0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1)));

if (PLOTHW=1 AND PLOTEP=0)

 

bandplot LimitUpper=HW_UCL LimitLower=HW_LCL x=TIME /

displayTail=false modelname="Survival" fillattrs=

GRAPHCONFIDENCE name="HW" legendlabel=LABELHW;

endif;

if (PLOTHW=0 AND PLOTEP=1)

 

bandplot LimitUpper=EP_UCL LimitLower=EP_LCL x=TIME /

displayTail=false modelname="Survival" fillattrs=

GRAPHCONFIDENCE name="EP" legendlabel=LABELEP;

endif;

if (PLOTHW=1 AND PLOTEP=1)

 

bandplot LimitUpper=HW_UCL LimitLower=HW_LCL x=TIME /

displayTail=false modelname="Survival" fillattrs=

GRAPHDATA1 datatransparency=.55 name="HW" legendlabel=

 

LABELHW;

bandplot LimitUpper=EP_UCL LimitLower=EP_LCL x=TIME /

displayTail=false modelname="Survival" fillattrs=

GRAPHDATA2 datatransparency=.55 name="EP" legendlabel=

 

LABELEP;

endif;

if (PLOTCL=1)

if (PLOTHW=1 OR PLOTEP=1)

 

bandplot LimitUpper=SDF_UCL LimitLower=SDF_LCL x=TIME /

displayTail=false modelname="Survival" display=(

outline) outlineattrs=GRAPHPREDICTIONLIMITS name="CL"

 

legendlabel=LABELCL;

else

 

bandplot LimitUpper=SDF_UCL LimitLower=SDF_LCL x=TIME /

displayTail=false modelname="Survival" fillattrs=

GRAPHCONFIDENCE name="CL" legendlabel=LABELCL;

endif;

endif;

stepplot y=SURVIVAL x=TIME / name="Survival" rolename=(_tip1=

ATRISK _tip2=EVENT) tiplabel=(_tip1="Number at Risk" _tip2=

"Observed Events") tip=(x y _tip1 _tip2) legendlabel=

"Survival";

if (PLOTCENSORED=1)

 

scatterplot y=CENSORED x=TIME / markerattrs=(symbol=plus)

tiplabel=(y="Survival Probability") name="Censored"

legendlabel="Censored";

endif;

if (PLOTCL=1 OR PLOTHW=1 OR PLOTEP=1)

discretelegend "Censored" "CL" "HW" "EP" / location=outside

 

halign=center;

else

if (PLOTCENSORED=1)

discretelegend "Censored" / location=inside autoalign=(

 

topright bottomleft);

endif;

endif;

if (PLOTATRISK=1)

 

innermargin / align=bottom;

axistable x=TATRISK value=ATRISK / display=(label)

valueattrs=(size=7pt);

endinnermargin;

endif;

layout gridded / columns=3 border=TRUE autoalign=(Top);

entry "";

entry "Event";

entry "Total";

entry halign=right STRVAL1 / textattrs=GRAPHDATA1;

entry NEVENT1 / textattrs=GRAPHDATA1;

entry NOBS1 / textattrs=GRAPHDATA1;

entry halign=right STRVAL2 / textattrs=GRAPHDATA2;

entry NEVENT2 / textattrs=GRAPHDATA2;

entry NOBS2 / textattrs=GRAPHDATA2;

entry halign=right STRVAL3 / textattrs=GRAPHDATA3;

entry NEVENT3 / textattrs=GRAPHDATA3;

entry NOBS3 / textattrs=GRAPHDATA3;

endlayout;

endlayout;

else

entrytitle "Kaplan-Meier Plot in Per Protocol Analysis Set";

 

if (EXISTS(SECONDTITLE))

entrytitle SECONDTITLE / textattrs=GRAPHVALUETEXT;

endif;

layout overlay / xaxisopts=(shortlabel=XNAME offsetmin=.05

linearopts=(viewmax=MAXTIME tickvaluelist=(0 7 14 21 28 35 42

49 56 63 70 77 84 91) tickvaluefitpolicy=XTICKVALFITPOL))

yaxisopts=(label="Cumulative Mortality" shortlabel="Mortality"

linearopts=(viewmin=.7 viewmax=1 tickvaluelist=(.7 .8 .9 1)));    /*here*/

if (PLOTHW=1)

 

bandplot LimitUpper=HW_UCL LimitLower=HW_LCL x=TIME /

displayTail=false group=STRATUM index=STRATUMNUM

modelname="Survival" datatransparency=Transparency;

endif;

if (PLOTEP=1)

 

bandplot LimitUpper=EP_UCL LimitLower=EP_LCL x=TIME /

displayTail=false group=STRATUM index=STRATUMNUM

modelname="Survival" datatransparency=Transparency;

endif;

if (PLOTCL=1)

if (PLOTHW=1 OR PLOTEP=1)

 

bandplot LimitUpper=SDF_UCL LimitLower=SDF_LCL x=TIME /

displayTail=false group=STRATUM index=STRATUMNUM

modelname="Survival" display=(outline) outlineattrs=(

 

pattern=ShortDash);

else

 

bandplot LimitUpper=SDF_UCL LimitLower=SDF_LCL x=TIME /

displayTail=false group=STRATUM index=STRATUMNUM

modelname="Survival" datatransparency=Transparency;

endif;

endif;

stepplot y=SURVIVAL x=TIME / group=STRATUM index=STRATUMNUM

name="Survival" rolename=(_tip1=ATRISK _tip2=EVENT) tiplabel

=(_tip1="Number at Risk" _tip2="Observed Events") tip=(x y

 

_tip1 _tip2);

if (PLOTCENSORED=1)

 

scatterplot y=CENSORED x=TIME / group=STRATUM index=

STRATUMNUM tiplabel=(y="Survival Probability")

 

markerattrs=(symbol=plus);

endif;

if (PLOTATRISK=1)

 

innermargin / align=bottom;

axistable x=TATRISK value=ATRISK / display=(label)

valueattrs=(size=7pt) class=CLASSATRISK colorgroup=

 

CLASSATRISK;

endinnermargin;

endif;

DiscreteLegend "Survival" / title="+ Censored" location=inside

autoalign=(Bottom);

if (PLOTCENSORED=1)

if (PLOTTEST=1)

layout gridded / rows=2 autoalign=(TOPRIGHT BOTTOMLEFT

 

TOP BOTTOM) border=true BackgroundColor=

GraphWalls:Color Opaque=true;

entry "+ Censored";

if (PVALUE < .0001)

entry "Log Rank p " eval (PUT(PVALUE, PVALUE6.4));

else

entry "Log Rank p = " eval (PUT(PVALUE, PVALUE6.4));

endif;

endlayout;

else

layout gridded / rows=1 autoalign=(TOPRIGHT BOTTOMLEFT

 

TOP BOTTOM) border=true BackgroundColor=

GraphWalls:Color Opaque=true;

entry "+ Censored";

endlayout;

endif;

else

if (PLOTTEST=1)

layout gridded / rows=1 autoalign=(TOPRIGHT BOTTOMLEFT

 

TOP BOTTOM) border=true BackgroundColor=

GraphWalls:Color Opaque=true;

if (PVALUE < .0001)

entry "Log Rank p " eval (PUT(PVALUE, PVALUE6.4));

else

entry "Log Rank p = " eval (PUT(PVALUE, PVALUE6.4));

endif;

endlayout;

endif;

endif;

layout gridded / columns=3 border=TRUE autoalign=(Top);

entry "";

entry "Event";

entry "Total";

entry halign=right STRVAL1 / textattrs=GRAPHDATA1;

entry NEVENT1 / textattrs=GRAPHDATA1;

entry NOBS1 / textattrs=GRAPHDATA1;

entry halign=right STRVAL2 / textattrs=GRAPHDATA2;

entry NEVENT2 / textattrs=GRAPHDATA2;

entry NOBS2 / textattrs=GRAPHDATA2;

entry halign=right STRVAL3 / textattrs=GRAPHDATA3;

entry NEVENT3 / textattrs=GRAPHDATA3;

entry NOBS3 / textattrs=GRAPHDATA3;

endlayout;

endlayout;

endif;

 

if (_BYTITLE_)

entrytitle _BYLINE_ / textattrs=GRAPHVALUETEXT;

else

 

if (_BYFOOTNOTE_)

entryfootnote halign=left _BYLINE_;

endif;

endif;

EndGraph;

end;

title4 'Kaplan-Meier Cumulative Failure to Day 90 in Per Protocol Analysis Set';

proc lifetest data=modPP plots= survival ( failure ) ;

time days_mort90*censor_mort90(1);

strata group /order=internal;

label group='Dose Group';

label days_mort90='Days to Death or Censor';

format group group.;

run;

 

Reeza
Super User
Did you mess around with the original templates? If so, it's possible you accidentally destroyed it. What version of SAS are you using, very specifically.

Run

proc product_status;
run;

Log will show SAS version and STAT version such as

SAS 9.4M6, SAS STAT 15.1
greg_maislin
Fluorite | Level 6
Here is the info. Interesting hypothesis that I destroyed the original
Stat.Lifetest.Graphics.ProductLimitFailure.

When I do ods trace on, I see a template generated. I will run same code
on different computer.





proc product_status;

6368 run;



For Base SAS Software ...

Custom version information: 9.4_M6

Image version information: 9.04.01M6P110718

For SAS/STAT ...

Custom version information: 15.1

For SAS/GRAPH ...

Custom version information: 9.4_M6

For SAS/ETS ...

Custom version information: 15.1

For SAS/FSP ...

Custom version information: 9.4_M6

For SAS/OR ...

Custom version information: 15.1

Image version information: 9.04.01M6P050819

For SAS/AF ...

Custom version information: 9.4_M6

For SAS/IML ...

Custom version information: 15.1

For SAS/QC ...

Custom version information: 15.1

For SAS/SHARE ...

Custom version information: 9.4_M5

For SAS/ASSIST ...

Custom version information: 9.4

Image version information: 9.04.01M0P061913

For SAS/CONNECT ...

Custom version information: 9.4_M6

For SAS/TOOLKIT ...

Custom version information: 9.4

For SAS/ACCESS to JDBC ...

Custom version information: 1.0

For SAS/EIS ...

Custom version information: 9.4_M6

For SAS/GIS ...

Custom version information: 9.4_M6

For SAS/ACCESS Interface to Netezza ...

Custom version information: 9.43

For SAS/ACCESS Interface to Aster nCluster ...

Custom version information: 9.44

For SAS/ACCESS Interface to Greenplum ...

Custom version information: 9.43

For SAS/ACCESS Interface to SAP IQ ...

Custom version information: 9.4_M5

For SAS/ACCESS to Hadoop ...

Custom version information: 9.46

For SAS Enterprise Miner ...

Custom version information: 15.1

For SAS/ACCESS to Vertica ...

Custom version information: 9.4_M6

For SAS/ACCESS to Postgres ...

Custom version information: 9.4_M6

For SAS/ACCESS to Impala ...

Custom version information: 9.45

For SAS/IntrNet ...

Custom version information: 9.4_M6

For SAS/ACCESS to Salesforce ...

Custom version information: 9.4

Image version information: 9.04.01M6P041019

For SAS/ACCESS to HAWQ ...

Custom version information: 9.4_M3

For SAS/ACCESS to Amazon Redshift ...

Custom version information: 9.43

For SAS Integration Technologies ...

Custom version information: 9.4_M6

For SAS Text Miner ...

Custom version information: 15.1

For SAS/Genetics ...

Custom version information: 15.1

For High Performance Suite ...

Custom version information: 2.2_M7

For SAS/ACCESS Interface to DB2 ...

Custom version information: 9.4_M2

For SAS/ACCESS Interface to Oracle ...

Custom version information: 9.43

For SAS/ACCESS Interface to the PI System ...

Custom version information: 9.44

For SAS/ACCESS Interface to SAP ASE ...

Custom version information: 9.4_M5

For SAS/ACCESS Interface to PC Files ...

Custom version information: 9.4_M6

For SAS/ACCESS Interface to ODBC ...

Custom version information: 9.4_M6

For SAS/ACCESS Interface to OLE DB ...

Custom version information: 9.4_M6

For SAS/ACCESS Interface to Teradata ...

Custom version information: 9.46

For SAS/ACCESS Interface to MySQL ...

Custom version information: 9.4_M6

NOTE: PROCEDURE PRODUCT_STATUS used (Total process time):

real time 0.66 seconds

cpu time 0.09 seconds




Reeza
Super User

Start a new session and run the code below, how does the graph look?

 

proc lifetest data=sashelp.BMT plots=surv(failure atrisk=0 to 2500 by 500);
   time T * Status(0);
   strata Group / test=logrank adjust=sidak;
run;

 Does it match the output attached? 

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!
What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 9 replies
  • 1074 views
  • 0 likes
  • 2 in conversation