New Contributor
Posts: 4

# Plotting cumulative hazard rate (Nelson Aalen curves)

Hello everyone,

I am working on survival data with incidence of cancer and some food consumption data in quartiles.

Exposition : quartile of sugared food

Confusion factor : age, BMI, sex.

Outcome : cancer

I would like to draw a curve of cumulative hazard rate function (for example with Nelson Aalen estimator, a non parametric estimator of the cumulative hazard rate function) like this graph below : where we would see the cumulative risk of cancer in function of the 4 quartiles of food consumption.

Caption of the graph : "Nelson-Aalen curves showing the outcome of new-onset overweight depending on ultraprocessed food consumption at baseline. Adjusted for sex, age, marital status, educational status"

If someone had an idea of a beginning of script, i would be really grateful.

i am doing Cox model with this type of script :

``````proc phreg data=mydata;
class sexe;
model survival_time*censure(1)=sexe age IMC;
strata quartile_ultraprocessed ;
run;``````

Thanks in advance, have a nice day,

Super User
Posts: 20,735

## Re: Plotting cumulative hazard rate (Nelson Aalen curves)

You'll want tthe 'statistical' style to get the curves in a similar format but you'll have to manually add the data at the top. If you can post it at the bottom of the graph that could be more easily incorporated.

Super Contributor
Posts: 301

## Re: Plotting cumulative hazard rate (Nelson Aalen curves)

You can get the cumulative hazard (Nelson Aalen) by using the baseline statement in PHREG;

As Nelson Aalen only can account for one combination of covariates at a time you will need to put all covariates into the strata statement.

Here is a simple example:

``````data test;
do i=1 to 100;
x=mod(i,2);
t=rand('exponential',1);
output;
end;
run;

proc phreg data=test;
model t=;
strata x;
baseline out=baseline cumhaz=cumhaz;
run; ``````

You can then plot the hazard by using proc gplot or sgplot.

New Contributor
Posts: 4

## Re: Plotting cumulative hazard rate (Nelson Aalen curves)

I tested your statements but I don't know why when I look at the table "baseline" created and containing "Cumulative Hazard function estimates", there are only about 2000 observations. And in my dataset of departure, I have about 100 000 observations (about 2200 events and 97 800 censored). Do you have an idea why I have this decrease ?

have a nice day,

Super Contributor
Posts: 301