BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
riyaaora275
Obsidian | Level 7

I have calculated the mean and median survival time from proc lifetest 

proc lifetest data=graph2;
ods output means = mean_surv quartiles= median_surv;
time time*status(0);
strata brand;
run;


However I cannot understand how this is calculated.

data have ;

input ID start_dt date9. end_dt date9. membership_end_dt date9. status brand ;

datalines;

1 01Jan2012 02Feb2013 02Sep2013 1 a

2 15Jan2012 25Feb2013 02Sep2012 0 a

3 19Jan2012 12Feb2013 22Sep2013 1 a

4 22Jan2012 06Feb2013 02Sep2012 0 b

5 01Jan2012 02Feb2013 02Sep2013 1 c

;

data have2;

set have;

cal_end = min(end_date,membership_end_dt );
time = cal_end - start_date ;
format cal_end date9.;

run;


This data is medication use data, we have the start and end date of episodes for each ID and membership end date as well. If the end_date of episode is greater than the membership date then we censor that to the membership end date( as we dont want to measure the time on medication if the ID is not enrolled) . Status is the variable which which IDs are censored.

 

I use the proc lifetest on have2 dataset and measure the mean and quartiles.

 

Q1what is the formula used for measuring this mean? 

.If I use the have2 dataset to measure mean time then I get a very different result. why is that? 

 

Q2. why are quartiles missing for some brands? 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
FreelanceReinh
Jade | Level 19

Hello @riyaaora275,

 

You can find the formulas for estimated mean and median survival time in section "Breslow, Fleming-Harrington, and Kaplan-Meier Methods" of the PROC LIFETEST documentation. Both formulas involve Kaplan-Meier estimates (because you used the default, KM, of option METHOD= of the PROC LIFETEST statement), so to replicate the results you would need to compute these first or take the values from table "Product-Limit Survival Estimates" in the PROC LIFETEST output (or the corresponding output dataset if you specify the OUTSURV= option).

 

Example: For brand=a in your sample data you have t0=0, t1=231, t2=390 and t3=398. The corresponding KM-estimates are 1, 1, 0.5 and 0, respectively. The estimated mean survival time is then computed as

1*(231-0)+1*(390-231)+0.5*(398-390)=394

 

If the Kaplan-Meier curve (i.e. the KM-estimates) does not drop below 0.75 (0.5, 0.25), the first quartile (median, third quartile) cannot be estimated (as is the case for brand=b in your sample data). This is possible only if the largest survival time is censored.

View solution in original post

1 REPLY 1
FreelanceReinh
Jade | Level 19

Hello @riyaaora275,

 

You can find the formulas for estimated mean and median survival time in section "Breslow, Fleming-Harrington, and Kaplan-Meier Methods" of the PROC LIFETEST documentation. Both formulas involve Kaplan-Meier estimates (because you used the default, KM, of option METHOD= of the PROC LIFETEST statement), so to replicate the results you would need to compute these first or take the values from table "Product-Limit Survival Estimates" in the PROC LIFETEST output (or the corresponding output dataset if you specify the OUTSURV= option).

 

Example: For brand=a in your sample data you have t0=0, t1=231, t2=390 and t3=398. The corresponding KM-estimates are 1, 1, 0.5 and 0, respectively. The estimated mean survival time is then computed as

1*(231-0)+1*(390-231)+0.5*(398-390)=394

 

If the Kaplan-Meier curve (i.e. the KM-estimates) does not drop below 0.75 (0.5, 0.25), the first quartile (median, third quartile) cannot be estimated (as is the case for brand=b in your sample data). This is possible only if the largest survival time is censored.

SAS Innovate 2025: Call for Content

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!

Submit your idea!

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
  • 1 reply
  • 1022 views
  • 2 likes
  • 2 in conversation