BookmarkSubscribeRSS Feed
katieusc
Fluorite | Level 6

Hey guys I am trying to caculate some hazard ratios for an interaction term between two variables (depression score and multimorbidity grouping) in a multivariable model. Each of these variables have three levels each. I would like to see all of the hazard ratios for the interaction between these two variables. However, whenever I use the class statement no interaction estimates are produced. I would love some help in trying to calculate these hazard ratios for the interaction term. Below I've posted some information that might be useful.

 

Thank you

 

Code I have been using:

proc phreg data=data1;
class grouping1 (ref='0') race (ref='1') education (ref='1') ragender (ref='1.Male') health (ref='1') smokenow (ref='0') physical (ref='0') depression (ref='2')/param=glm;
model duration*status(0)= grouping1 R7AGEY_M race education ragender health smokenow physical BMI depression grouping1*depression /risklimits;
contrast 'Md vs Low Grouping 0' Group 1 0 Grouping1 0 1 Group*Grouping1 1 -1 1/estimate=exp e;
run;

 

Class Level Information:

SAS Output

Grouping1 1   2   0
100 
010 
001

SAS Output

Depression   1  3   2
100 
010 
001

 

5 REPLIES 5
SAS_Rob
SAS Employee

There is an HAZARDRATIO statement that will allow you to get hazard ratios in the presence of an interaction.

 

http://support.sas.com/documentation/cdl/en/statug/68162/HTML/default/viewer.htm#statug_phreg_syntax...

 

katieusc
Fluorite | Level 6

Thanks for your help Rob. I ran the following code and was wondering how you get the traditional printout where you would see for example Grouping1 2 Depression 3. Instead I am getting Grouping1 1vs 2 at Depression=1.

 

Partial Code:

 

hazardratio grouping1 / diff=distinct at (group=all);
hazardratio group/ diff=distinct at (grouping1=all);

 

Printout:

 

SAS Output

Hazard Ratios for Grouping1 Description Point Estimate 95% Wald Confidence Limits Grouping1 1 vs 2 At Depression=1 Grouping1 1 vs 0 At Depression=1 Grouping1 2 vs 0 At Depression=1 Grouping1 1 vs 2 At Depression=3 Grouping1 1 vs 0 At Depression=3 Grouping1 2 vs 0 At Depression=3 Grouping1 1 vs 2 At Depression=2 Grouping1 1 vs 0 At Depression=2 Grouping1 2 vs 0 At Depression=2
0.6380.5890.690
1.4531.3401.576
2.2802.0662.516
0.6380.5890.690
1.4531.3401.576
2.2802.0662.516
0.6380.5890.690
1.4531.3401.576
2.2802.0662.516

 

SAS Output

Hazard Ratios for Depression Description Point Estimate 95% Wald Confidence Limits Depression 1 vs 3 At Grouping1=1 Depression 1 vs 2 At Grouping1=1 Depression 3 vs 2 At Grouping1=1 Depression 1 vs 3 At Grouping1=2 Depression 1 vs 2 At Grouping1=2 Depression 3 vs 2 At Grouping1=2 Depression 1 vs 3 At Grouping1=0 Depression 1 vs 2 At Grouping1=0 Depression 3 vs 2 At Grouping1=0
0.9650.8831.056
1.1101.0271.199
1.1501.0511.257
0.9650.8831.056
1.1101.0271.199
1.1501.0511.257
0.9650.8831.056
1.1101.0271.199
1.1501.051

1.257 

 

Thanks for your help!

SAS_Rob
SAS Employee

Are you saying that you want to compare the different cells in the two-way interaction rather than comparisons where one of the effects is held constant?

 

If so, then you can just put the interaction on the HAZARDRATIO statement and it will give you each of the comparisons.

katieusc
Fluorite | Level 6

Yes, that is what I am trying to do. When I add the interaction statement, "hazardratio grouping1*depression;" it says syntax error and does not solve. Do you know what I am missing?

 

Thank you for all of your help.

SAS_Rob
SAS Employee

Thinking more about this, that won't work as it will only give the individual comparisons for one of the variables.

 

 

An easier and direct way would be to use the LSMEANS statement with the DIFF, EXP and  CL option.  You will also need to make sure you use GLM coding so you can get the LSMEANS 

 

class grouping1 (ref='0') race (ref='1') education (ref='1') ragender (ref='1.Male') health (ref='1') smokenow (ref='0') physical (ref='0') depression (ref='2')/param=glm;
model duration*status(0)= grouping1 R7AGEY_M race education ragender health smokenow physical BMI depression grouping1*depression /risklimits;

lsmeans grouping1*depression/cl diff exp;

run;

 

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

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
  • 5 replies
  • 10735 views
  • 2 likes
  • 2 in conversation