Censored vs Event in Proc lifetest and Proc phreg using SAS

 

/*MOCK DATA*/

/*First step : Derive censored or LOA event for each subject Based on the definitions below from SAP, for example use  week 96 as a cut-off */

/*The time to LOA is defined as the time from randomization to the time of first visit that the LOA criteria are met. 

Patients without LOA per the definition will be censored at the last observation time point. */

/*A value of 0 indicates a censored observation, while a value of 1 indicates an event.*/

data survival_data;

  input id time status treatment $ treatment_n age genotype $;

  datalines;

1  5  1 Placebo 0 40 GenA

2  7  0 Placebo 0 55 GenB

3  6  1 Placebo 0 60 GenA

4  9  1 Placebo 0 50 GenC

5  4  0 Placebo 0 45 GenB

6  8  1 Placebo 0 52 GenA

7  3  1 Active  1 43 GenA

8  5  0 Active  1 46 GenB

9  6  1 Active  1 49 GenC

10 9  1 Active  1 58 GenB

11 7  0 Active  1 53 GenC

12 8  1 Active  1 47 GenA

13 4  1 Placebo 0 44 GenB

14 10 0 Active  1 56 GenC

15 9  1 Placebo 0 59 GenA

16 6  1 Active  1 41 GenB

;

run;



/*Second Step: check the K-M plot,Performs log-rank test comparing survival distributions across levels of treatment, whether the two survival lines by different treatment group are crossed or parallel. If almost parallel, you can conduct the cox model below*/

proc lifetest data=survival_data plots=survival(atrisk=0 to 20 by 2); 

  time time*status(0);

  strata treatment;

run;

/*Third Step*/

/*Supplemental Analyses

Cox proportional hazards regression analysis will be conducted with treatment group, genotype and age group as covariates. Hazard ratio and associated 95% confidence intervals will be estimated. 

*/


ods select none; 

ods output ParameterEstimates=param_est

           HazardRatios=hr_est;

proc phreg data=survival_data;

  class treatment (ref='Placebo') genotype / param=ref; /* specify reference level */

  model time*status(0) = treatment age genotype/*genotype only for comined column*/;

  hazardratio treatment / cl=both;  /* show HR and 95% CI for treatment */

run;

ods select all; 



/*get p-value from param_est, row=parameter=treatment, column=pr>chisq*/

/*get hazard ratio,Wald-based CI from hr-est*/




In SAS survival procedures like PROC PHREG,

time*status(censor_code) tells SAS which values in your event indicator mean “no event yet” (censored).


How it works

  • status variable = indicator of whether the event happened

    • Could be coded 0/1, or with other numeric or character values.

  • The value you put inside parentheses = the censor code(s).

  • SAS will treat all values in parentheses as censored.

  • All other values = event occurred.


Examples

1. Event coded as 1, censored coded as 0 (most common)

sas
model time*status(0) = ...;
  • status = 0 → censored (no event at last follow-up)

  • status = 1 → event occurred


2. Event coded as 0, censored coded as 1 (less common)

sas
model time*status(1) = ...;
  • status = 1 → censored

  • status = 0 → event occurred


3. Multiple censor codes

If your data uses different numbers for different censoring reasons:

sas
model time*status(0,2) = ...;
  • status = 0 or status = 2 → censored

  • All other values → event


Rule of thumb

  • Look at how your event variable is coded.

  • Put the value(s) for censored observations in parentheses.

  • Do not put the event value(s) in parentheses.


Comments

Popular posts from this blog

Analysis of Repeated Measures Data using SAS

Medical information for Melanoma, Merkel cell carcinoma and tumor mutation burden

Four essential statistical functions for simulation in SAS