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;
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
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;
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
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;
And for a smoothed line rather than a step function:
proc sgplot data=ple;
pbspline x=dur y=cumhaz;
run;
Steve Denham
Thank you guys so much! This is great!
Pep
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
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.