BookmarkSubscribeRSS Feed
Minki
Calcite | Level 5

Hello,

 

we're using PROC PHREG to model a Cox regression with 3 time-dependent covariates and want to test if all 3 interactions from this time-dependent covariates equals zero, but we are unable to create a correct TEST statement. The code without the TEST statement (which we assume as valid):

proc phreg data = tteana;<br />  class trtpn(ref="1") region; * TRTPN has values 0 or 1, REGION has 4 categories ;<br />  model aval * cnsr(1) = trtpn region aeno1 aeno2 aeno3 aeno1*trtpn aeno2*trtpn aeno3*trtpn / rl;<br />  * TIM1, TIM2, and TIM3 as well as AVAL are time variables ;<br />  if tim1 <= .z or aval <= tim1 then do;<br />    aeno1 = 0; aeno2 = 0; aeno3 = 0; <br />  end;<br />  else do;<br />    if (aval > tim1 and (aval <= tim2 or tim2 = .)) THEN DO;<br />      aeno1 = 1; aeno2 = 0; aeno3 = 0; <br />    end; <br />    else do;<br />      if (aval > tim2 and (aval <= tim3 or tim3 = .)) THEN DO;<br />        aeno1 = 0; aeno2 = 1; aeno3 = 0;<br />      end; <br />      else do;<br />        if (aval > tim3 ) THEN DO;<br />          aeno1 = 0; aeno2 = 0; aeno3 = 1;<br />        end; <br />      end;<br />    end;<br />  end;<br />  *T1: test aeno1*trtpn = aeno2*trtpn = aeno3*trtpn = 0;<br />run;

The TEST statement does not work and issues an error message (the * is not allowed).

 

The idea we had, was to create 3 new variables DUMMY1-DUMMY3, which are the same as the interaction terms the following way:

 

proc phreg data = tteana;<br />  class trtpn(ref="1") region ;<br />  model aval * cnsr(1) = trtpn region aeno1 aeno2 aeno3 dummy1 dummy2 dummy3 / RL;<br />  if tim1 <= .z or aval <= tim1 then do;<br />    aeno1 = 0; dummy1 = aeno1*trtpn;<br />    aeno2 = 0; dummy2 = aeno2*trtpn;<br />    aeno3 = 0; dummy3 = aeno3*trtpn;<br />  end;<br />  else do;<br />    if (aval > tim1 and (aval <= tim2 or tim2 = .)) then do;<br />      aeno1 = 1; dummy1 = aeno1*trtpn;<br />      aeno2 = 0; dummy2 = aeno2*trtpn;<br />      aeno3 = 0; dummy3 = aeno3*trtpn;<br />    end; <br />    else do;<br />      if (aval > tim2 and (aval <= tim3 or tim3 = .)) then do;<br />        aeno1 = 0; dummy1 = aeno1*trtpn;<br />        aeno2 = 1; dummy2 = aeno2*trtpn;<br />        aeno3 = 0; dummy3 = aeno3*trtpn;<br />      end; <br />      else do;<br />        if (aval > tim3 ) then do;<br />          aeno1 = 0; dummy1 = aeno1*trtpn;<br />          aeno2 = 0; dummy2 = aeno2*trtpn;<br />          aeno3 = 1; dummy3 = aeno3*trtpn;<br />        end; <br />      end;<br />    end;<br />  end;<br />  T1: Test dummy1 = dummy2 = dummy3 = 0;<br />run; 

 We get a result from the TEST statement, but the estimates for AENO1, AENO2, AENO3 are different from the ones in the first procedure run, the estimates for REGION are the same, the estimates for DUMMY1-DUMMY3 are the negative of the estimates of AEON1*TRTPN, AEON2*TRTPN, AEON3*TRTPN above.

 

Our questions:

Are the both models the same?

    If yes, why are the estimates for different?

    If no, what exactly is the difference between the two models?

Is there any other way to get the test result we want?

 

Any help would be greatly appreciated and thanks in advance trying to understand our problem!

2 REPLIES 2
ballardw
Super User

Please look closely at the "code" as posted. You have html tags and such in it like <br />. So we have no idea what code you may have actually submitted.

 

You may want to try reposting code using the code box opened with the {I} icon or copy from a different application.

 

When you get error messages it is a good idea to copy from the LOG the entire code for the Procedure or data step that throws the error and any messages. Paste into a code box opened using the forum's {I} or running man icons.

Minki
Calcite | Level 5

In the SAS code above <BR> line breaks are inserted, here's a new try, hopefully the code looks better now:

 

First code:

proc phreg data=tteana;
  class trtpn(ref='1') region;
  model aval * cnsr(1) = trtpn region aeno1 aeno2 aeno3 aeno1*trtpn aeno2*trtpn aeno3*trtpn / rl;
  if tim1 <= .z or aval <= tim1 then do;
    aeno1 = 0; aeno2 = 0; aeno3 = 0; 
  end;
  else do;
    if (aval > tim1 and (aval <= tim2 or tim2 = .)) then do;
      aeno1 = 1; aeno2 = 0; aeno3 = 0;
    end;        
    else do;
      if (aval > tim2 and (aval <= tim3 or tim3 = .)) then do;
        aeno1 = 0; aeno2 = 1; aeno3 = 0;
      end;           
      else do;
        if (aval > tim3 ) then do;
          aeno1 = 0; aeno2 = 0; aeno3 = 1; 
        end;  
      end;
    end;
  end;
* T1: Test aeno1*trtpn = aeno2*trtpn = aeno3*trtpn = 0; run;

Second code:

proc phreg data = tteana;
  class trtpn(ref='1') region;
  model aval * cnsr(1) = trtpn region aeno1 aeno2 aeno3 dummy1 dummy2 dummy3 / rl;
  if tim1 <= .z or aval <= tim1 then do;
    aeno1 = 0; dummy1 = aeno1*trtpn;
    aeno2 = 0; dummy2 = aeno2*trtpn;
    aeno3 = 0; dummy3 = aeno3*trtpn;
  end;
  else do;
    if (aval > tim1 and (aval <= tim2 or tim2 = .)) then do;
       aeno1 = 1; dummy1 = aeno1*trtpn;
       aeno2 = 0; dummy2 = aeno2*trtpn;
       aeno3 = 0; dummy3 = aeno3*trtpn;
    end;        
    else do;
      if (aval > tim2 and (aval <= tim3 or tim3 = .)) then do;
        aeno1 = 0; dummy1 = aeno1*trtpn;
        aeno2 = 1; dummy2 = aeno2*trtpn;
        aeno3 = 0; dummy3 = aeno3*trtpn;
      end;           
      else do;
        if (aval > tim3 ) then do;
          aeno1 = 0; dummy1 = aeno1*trtpn;
          aeno2 = 0; dummy2 = aeno2*trtpn;
          aeno3 = 1; dummy3 = aeno3*trtpn;
        end;  
      end;
    end;
  end;
run;
T1: Test dummy1 = dummy2 = dummy3 = 0;

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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
  • 2 replies
  • 534 views
  • 0 likes
  • 2 in conversation