Programming the statistical procedures from SAS

Kaplan-Meier Curve: How to show number censored below plot?

Posts: 54

Kaplan-Meier Curve: How to show number censored below plot?

Hi SAS Community,


I found a way to tailor my Kaplan-Meier plots to present the data I need to show, including number of subjects at risk. The only issue is that now I need to add the number censored in brackets next to the number at risk at each time point (every 500 days). I don't know how to modify the code to do this. The only option I have at the moment is the calculate the number censored by hand and add it in at the bottom using powerpoint, which is less than optimal due to formatting issues and potential for human error. Any help would be greatly appreciated. My code is below. Thank you.


data _null_;

   %let url = //;

   infile "http:&url/templft.html" device=url;


   file 'macros.tmp';

   retain pre 0;


   _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;



%inc 'macros.tmp' / nosource;


* Modify the template;


%let TitleText0 = "Kaplan-Meier Plot: Probability of death, stratified by CD4 count at time of HIV diagnosis";

%let yOptions = label="Survival Probability"

                linearopts=(viewmin=0.7 viewmax=1 tickvaluelist=(0.7 0.8 0.9 1.0));

%let xOptions = label="Time (days since release)" ;

%let GraphOpts = DataContrastColors=(green red blue)

DataColors=(green red blue);

/*%let TitleText1 = &titletext0 "CD4 count at diagnosis " STRATUMID;*/



*KM stratified by AIDS STAGE**************************************************************;

proc format ;

invalue CD4_atdiagnosiscat '>=500 cells/µL' = 1 '200-499 cells/µL' = 2 '<200 cells/µL' = 3;

value CD4_atdiagnosisfmt 1 = '>=500 cells/µL' 2 = '200-499 cells/µL' 3 = '<200 cells/µL';


data tempCD4(drop=g);

set CLEAN.databasesurv3(rename=(CD4_atdiagnosis=g));

CD4_atdiagnosis = input(g, CD4_atdiagnosiscat.);


* Analysis;

ods graphics on;

proc lifetest data=work.tempCD4 method=km atrisk

    plots=(S(test nocensor atrisk(maxlen=16 outside(0.12))=0 to 3000 by 500));

    time time*EVENT_ANYDEATH(0);

    strata CD4_atdiagnosis / order=internal adjust=sidak test=logrank ;

label CD4_atdiagnosis = "CD4 count at diagnosis";

    format CD4_atdiagnosis CD4_atdiagnosisfmt.;


ods graphics off;

Ask a Question
Discussion stats
  • 0 replies
  • 1 in conversation