Hi,
How do I find the hazard function estimate for a categorical variable using weibull distribution.
My categorical variable is categorical variable is Tumt: 0=large,1=squamous,2=small,3=adeno
I want hazard function for patients with large tumors (large =0).
I see that proc lifereg can be used to calculate weibull distribution but I don't know how to get the hazard function for a specific categorical variable or can I use proc lifetest? if yes how do I code it pls.
This is my code:
proc lifereg data=Cancer ;
class tumt ;
model survdays*dead(0) = treat tumt / dist=Weibull;
probplot;
inset;
run;
To calculate the hazard function estimate for a categorical variable using the Weibull distribution in SAS, you can use the PROC LIFEREG
procedure. The PROC LIFEREG
procedure allows you to fit a parametric survival model to your data, and then use the fitted model to estimate the hazard function for different groups of subjects.
In your case, you want to calculate the hazard function for patients with large tumors (tumt = 0). To do this, you can use the PROC LIFEREG
statement to fit a Weibull model to your data, and then use the HAZARD
option in the MODEL
statement to request that the procedure estimate the hazard function for each level of the tumt
variable. Here is an example of how you might do this in SAS:
PROC LIFEREG DATA=Cancer;
CLASS tumt;
MODEL survdays*dead(0) = treat tumt / DIST=WEIBULL HAZARD;
PROBPLOT;
INSET;
RUN;
In this example, the PROC LIFEREG
statement specifies that you want to fit a Weibull model to the data in the Cancer
dataset. The CLASS
statement indicates that the tumt
variable is a categorical variable, and the MODEL
statement specifies the model that you want to fit. The HAZARD
option in the MODEL
statement tells SAS to estimate the hazard function for each level of the tumt
variable.
After running this code, you can use the PROBPLOT
and INSET
statements to create a probability plot that shows the estimated hazard functions for each level of the tumt
variable. You can then use this plot to compare the hazard functions for different tumor types and identify any differences in the hazard of death for patients with different tumor types.
Alternatively, you can use the PROC LIFETEST
procedure to calculate the hazard function for a specific group of subjects. For example, if you want to calculate the hazard function for patients with large tumors (tumt = 0), you could use the following code:
PROC LIFETEST DATA=Cancer;
TIME survdays*dead(0);
STRATA tumt;
TEST / HAZARD;
RUN;
In this code, the PROC LIFETEST
statement specifies that you want to perform a survival analysis on the data in the Cancer
dataset. The TIME
statement indicates the time-to-event variable and the event variable, and the STRATA
statement indicates that you want to stratify the data by the tumt
variable. The TEST
statement specifies that you want to calculate the hazard function for each stratum (i.e. for each level of the tumt
variable).
I hope this helps! Let me know if you have any other questions.
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 25. 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.