Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Home
- /
- Analytics
- /
- Stat Procs
- /
- Kaplan-Meier Curve: How to show number censored below plot?

Options

- RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Posted 07-01-2018 11:57 AM
(2675 views)

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_, '<' , '<');

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;

3 REPLIES 3

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

This example is from one of my tutorials. The point is you can construct a macro that adds DRAW statements to enhance the graph in any way. If you need to make the contents depend on data, you can do that too. You could use CALL EXECUTE to write the statements. While this paper does not do what you ask, it shows the incredible lengths you can go to to customize graphs. https://www.pharmasug.org/proceedings/2018/DV/PharmaSUG-2018-DV03.pdf

```
%ProvideSurvivalMacros
%macro StmtsBeginGraph;
* Coordinates are ad hoc, and there are many
available coordinate systems.
See the documentation for more information.;
drawtext textattrs=(weight=Bold) 'Number at Risk' /
x=5 y=14 width=9;
%mend;
%CompileSurvivalTemplates
proc lifetest data=sashelp.BMT
plots=survival(atrisk outside maxlen=13);
time T * Status(0);
strata Group;
run;
```

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

I have the same question. I want show #in-risk(#censored) at each time interval below KM plot. #censored is #patients who did not have event but lost follow up prior the time point (Censored at last contact), they are hash markers in survival curve.

Thanks!

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

**Don't miss out on SAS Innovate - Register now for the FREE Livestream!**

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.