Tell me more ×
Cross Validated is a question and answer site for statisticians, data analysts, data miners and data visualization experts. It's 100% free, no registration required.

In PROC PHREG, how do you set a continuous variable at a certain value as the reference level? For example, suppose x = 3.5, 3.6, 4.3, 5.4 and we want x = 6 to be the reference level. How would you do this in SAS?

Would this be correct:

      data new; 
        set old;
        x1 = (x=3.5);
        x2 = (x= 3.6);
        x3 = (x = 4.3);
        x4 = (x= 5.4);

       proc phreg data = new; 
         class x ( ref = '6');
         model time*censor(0) = x1 x2 x3 x4 /r1; 
       run; 

Edit. Actually, could one just use the point estimate of the coefficient of $x$? In other words suppose the estimated coefficient for $x$ is $0.512$. Then the hazard ratio between $x = 3.5$ and $x = 6$ would be $\exp(0.512(3.5-6))$, the hazards ratio between $x = 3.6$ and $x = 6$ would be $\exp(0.512(3.6-6))$ etc...?

So there is no need to even form these groups? Just do the following:

    proc phreg data = new;
       model time*censor(0) = x /r1;
    run; 
share|improve this question
Doesn't SO have a SAS section? I thought SE was for theory. – DWin Dec 11 '11 at 18:34

1 Answer

If X is a continuous variable, there is no reference level; or, I guess, in a way, the reference level is 0. Then you could, sort of, change the reference level to 6 by forming a new variable x2 = x - 6. Then you could use your second code.

If you want to treat x as a class variable, then (unfortunately) there's no easy way to set the reference level in SAS. One thing you can do is either format the variable so thath that the reference level comes last, or create a new variable something like this:

data new;
 set old;
 if x = 3.5 then x2 = 'A:3.5';
 else if x = 3.6 then x2 = 'B:3.6';

....
run;

then

   proc phreg data = new;
       class x2
       model time*censor(0) = x2 /r1;
    run; 

That loses the continuity and ordinality of x, but that may be desirable (to capture nonlinearity and because your x are not very evenly spaced). However, I suggest exploring polynomial terms and/or splines.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.