Programming the statistical procedures from SAS

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

Reply
Contributor
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 = //support.sas.com/documentation/onlinedoc/stat/ex_code/142;

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

 

   file 'macros.tmp';

   retain pre 0;

   input;

   _infile_ = tranwrd(_infile_, '&', '&');

   _infile_ = tranwrd(_infile_, '&lt;' , '<');

   if index(_infile_, '</pre>') then pre = 0;

   if pre then put _infile_;

   if index(_infile_, '<pre>')  then pre = 1;

run;

 

%inc 'macros.tmp' / nosource;

 

* Modify the template;

%ProvideSurvivalMacros

%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;*/

%CompileSurvivalTemplates

 

*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';

run;

data tempCD4(drop=g);

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

CD4_atdiagnosis = input(g, CD4_atdiagnosiscat.);

run;

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

run;

ods graphics off;

Ask a Question
Discussion stats
  • 0 replies
  • 83 views
  • 0 likes
  • 1 in conversation