I am working on a project which involves fitting a Cox proportional hazard model to a time to event situation in SAS. We have the variables:
- y - event or censor (0/1)
- timeto - time to event y
- x - categorical variable that takes the value (1,2,3,4) which represents group 1,2,3,4
The SAS code I am using is:
proc phreg data=data1;
class x;
model timeto*y(0) = x / ties=efron rl;
hazardratio x / diff=all;
run;
I would then get the desired hazard ratios (HR) outputs for
- group 1 vs. 2
- group 1 vs. 3
- group 1 vs. 4 (this is the HR of interest, HR=0.5151, let's say)
- group 2 vs. 3
- group 2 vs. 4
- group 3 vs. 4
Then when I was asked to combine group 2 and 3 for simplicity purpose. So I did a simple data step:
data data1;
set data1;
if x=2 then x=3; *simply put all group 2 observations to group 3;
run;
Then when I run the proc phreg code again, I get the HR outputs
- group 1 vs. 3
- group 1 vs. 4 (this becomes different, HR=0.4988)
- group 3 vs. 4
From what I understand the HR for group 1 vs group 4 should not change based on the formula in https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.3/statug/statug_phreg_details24.htm.
I am not an expert, and I really wonder why the HR changes after regrouping. Might someone be willing to explain to me?