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