BookmarkSubscribeRSS Feed
npandis
Fluorite | Level 6

Hi,

I have two categorical variables coded 0/1

Can I add their interaction like var1*var2 in proc nlmixed?

Would the procedure correctly recognise it and treat it correctly or do I need to create dummy variables?

Thank you,

Nikos

3 REPLIES 3
Rick_SAS
SAS Super FREQ

Since PROC NLMIXED does not have a CLASS statement, you need to construct the interaction terms yourself. Robin High has an example in his SGF paper.

 

The other alternative is to use a SAS procedure to output the design matrix, which will include the interaction term as a separate column. If the column is named Var12, you can then use the interaction in the model.

npandis
Fluorite | Level 6

Thank Rick.

I have seen this paper and my understanding is that the goal is to convert the categorical variables to dummy 0/1 vars. This especially important when categorical vars have more than 2 levels. My 2 categorical vars have only two levels and are already coded 0/1.

However, I am not sure if I am ok.

Best,

Nikos

 

StatDave
SAS Super FREQ

Since you say you only have two binary predictors, there is only 1 degree of freedom for each main effect and their interaction. So you could use a model specification like this, assuming the variables are A and B with values 'yes' and 'no':

 

ba*(a='yes') + bb*(b='yes') + bab*(a='yes')*(b='yes')

 

You can see examples of using this construction in these notes: 60240, 3722848506 and 44931.

 

 

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 3 replies
  • 935 views
  • 0 likes
  • 3 in conversation