BookmarkSubscribeRSS Feed
CarlosNunez
Calcite | Level 5

I am just wondering if there is a mistake with the attached code since the class level information for sex is female = 0 and male = 1, the first part of the code is contrasting different groups in males and the value used was zero. Should it not be 1 instead?. Can some explain how the contrast statement works in an interaction?

5 REPLIES 5
LinusH
Tourmaline | Level 20
Please don't attach office documents.
If it's code just paste it into the code editor in the post.
Data never sleeps
CarlosNunez
Calcite | Level 5
 
Class Level Information
Class Value Design Variables
group A 1 0
          B 0 1
          C 0 0
sex Female 0
      Male 1
 
proc phreg data=sasuser.ami;
class group(ref='C') sex(ref='Female') / param=ref order=internal;
model days*status(0) = group sex group*sex / ties=Efron;
* Contrasts among groups for SEX=Male and SEX=Female. *;
contrast 'AvsB sex=Male' group 1 -1 sex 0 group*sex 1 -1 / estimate=exp e;
contrast 'AvsC sex=Male' group 1 0 sex 0 group*sex 1 0 / estimate=exp e;
contrast 'BvsC sex=Male' group 0 1 sex 0 group*sex 0 1 / estimate=exp e;
contrast 'AvsB sex=Female' group 1 -1 sex 0 group*sex 0 0 / estimate=exp e;
contrast 'AvsC sex=Female' group 1 0 sex 0 group*sex 0 0 / estimate=exp e;
contrast 'BvsC sex=Female' group 0 1 sex 0 group*sex 0 0 / estimate=exp e;
* Contrasts among sexes for groups A, B, and C. *;
contrast 'Male vs Female group=A' group 0 0 sex 1 group*sex 1 0 /
estimate=exp e;
contrast 'Male vs Female group=B' group 0 0 sex 1 group*sex 0 1 /
estimate=exp e;
contrast 'Male vs Female group=C' group 0 0 sex 1 group*sex 0 0 /
estimate=exp e;
* Contrast that cannot be replicated with a HAZARDRATIO statement. This *;
* contrast compares group A with the average of groups B and C for males. *;
contrast 'A vs (B+C)/2 at sex=Male' group 1 -0.5 sex 0 group*sex 1 -0.5 /
estimate=exp e;
run;
StatDave
SAS Super FREQ

If you want to make simple pairwise comparisons, it is always easiest to use the LSMEANS, LSMESTIMATE, or SLICE statement since this allows you to avoid the always error-prone process of determining contrast coefficients for the CONTRAST or ESTIMATE statement. This is discussed and illustrated in detail in this note. For a model with interaction, you can use the SLICE statement to simplify getting your comparisons. 

CarlosNunez
Calcite | Level 5

Hi all,

 

I am testing an interaction between two categorical variables; the first variable has 5 levels and the other has 4. However, I just want to contrast some levels of this interaction and obtain an overall p-value for those interaction terms being contrasted. Is that possible? if so how?

 

Any help would be appreciated.

StatDave
SAS Super FREQ

The note I referred to shows exactly the sort of comparisons you seem to want in your original post. Please look over the examples. The SLICE, LSMEANS, and LSMESTIMATE statements work the same way in any modeling procedure that supports them.

 

slice group*sex / sliceby=sex; 

and

slice group*sex / sliceby=group;

 

Note that you need to use PARAM=GLM (not REF) in the CLASS statement to use SLICE, LSMEANS, or LSMESTIMATE.  See the documentation of the SLICE and LSMEANS statements in your modeling procedure to see the additional options that are available.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 1772 views
  • 6 likes
  • 3 in conversation