BookmarkSubscribeRSS Feed
Pepperoni
Calcite | Level 5

Hi everyone,

I have to plot the Nelson-Aalen estimate of the cumulative hazard function, and it's giving me some trouble. SAS references say to specify METHOD=NELSON within proc lifetest, but I can't figure out the actual line command. So here is my code, with question marks inserted about specifying the Nelson-Aalen calculation, and how to specify the graph type (I want the cumulative hazard function). Can anyone help an enthusiastic but clueless newbie? Any suggestions appreciated!

Many thanks,

Pep

data hepatitis;
input dur status;
datalines;
1 1
1 1
1 1
1 0
4 0
5 1
7 1
8 1
10 1
10 0
12 0
16 0
16 0
16 0
;
ods rtf;

proc lifetest data=hepatitis ????? plot=(????);
time dur*status(0);
run;
ods rtf close;

6 REPLIES 6
SteveDenham
Jade | Level 19

Not real sure if this is what you want, but it did run and gave a smoothed plot of the estimated hazard rate.

proc lifetest data=hepatitis nelson plots=h;

time dur*status(0);

ods output productlimitestimates=ple;

run;

The dataset ple has the Nelson-Aalen estimates (along with some other stuff).  You could then plot the cumulatives using PROC SGPLOT, using the PBSPLINE option.  I am afraid that is outside my skill set, though.

Steve Denham

Pepperoni
Calcite | Level 5

OK, so I got the code below to give me the estimates I needed, but I still need to produce a graph of the Nelson-Aalen cumulative hazard function plotted over time. Any ideas as to which line of code could help me do it?

Thanks!

Pep

data hepatitis;

input dur status;

datalines;

1 1

1 1

1 1

1 0

4 0

5 1

7 1

8 1

10 1

10 0

12 0

16 0

16 0

16 0

;

ods rtf;

run;


proc lifetest data=hepatitis nelson;
  time dur*status(0);
   run;

ods rtf close;

SteveDenham
Jade | Level 19

Use the ods output statement I gave (ods output productlimitestimates=ple) to get a dataset with the cumulative hazards estimates.  Then plot it using PROC SGPLOT.

Steve Denham

PGStats
Opal | Level 21

And that would be something like:

proc lifetest data=hepatitis nelson;

time dur*status(0);

ods output ProductLimitEstimates=ple;

run;

proc sgplot data=ple;

step x=dur y=cumhaz;

run;

PG
SteveDenham
Jade | Level 19

And for a smoothed line rather than a step function:

proc sgplot data=ple;

pbspline x=dur y=cumhaz;

run;

Steve Denham

Pepperoni
Calcite | Level 5

Thank you guys so much! This is great!

Pep

sas-innovate-2024.png

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.

 

Register now!

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.

Discussion stats
  • 6 replies
  • 9327 views
  • 0 likes
  • 3 in conversation