Add shade to Kaplan Meier plot

This post was kindly contributed by SAS & Statistics - go there to comment and to read the full post.

data km;
  seed=12345;
  do loc=1 to 2;
    do time=2 to 22 by 1+int(4*ranuni(seed));
      status=int(2*ranuni(seed));
      output;
    end;
  end;
run;

proc lifetest data=km plots=s outsurv=os;
  ods select survivalplot;
  time time*status(1);
  strata loc;
run;

data os;
  retain survhold 1;
  set os;
  if _censor_ = 1 then  SURVIVAL= survhold;
  else survhold= SURVIVAL;
run;

proc sgplot data=os;
  step x=time y=Survival / name=”survival” legendlabel=”Survival” group=stratum;
  band x=time lower=0 upper=survival / modelname=”survival” transparency=.5;
run;

This post was kindly contributed by SAS & Statistics - go there to comment and to read the full post.