Programming the statistical procedures from SAS

Plotting the Nelson-Aalen estimate

Reply
Occasional Contributor
Posts: 13

Plotting the Nelson-Aalen estimate

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;

Respected Advisor
Posts: 2,655

Plotting the Nelson-Aalen estimate

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

Occasional Contributor
Posts: 13

Plotting the Nelson-Aalen estimate

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;

Respected Advisor
Posts: 2,655

Plotting the Nelson-Aalen estimate

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

Respected Advisor
Posts: 4,756

Plotting the Nelson-Aalen estimate

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
Respected Advisor
Posts: 2,655

Plotting the Nelson-Aalen estimate

And for a smoothed line rather than a step function:

proc sgplot data=ple;

pbspline x=dur y=cumhaz;

run;

Steve Denham

Occasional Contributor
Posts: 13

Plotting the Nelson-Aalen estimate

Thank you guys so much! This is great!

Pep

Ask a Question
Discussion stats
  • 6 replies
  • 3544 views
  • 0 likes
  • 3 in conversation