In statistics, moderation occurs when the relationship between two variables depends on a third variable. In this case, the third variable is referred to as the moderating variable, or simply the moderator. The effect of the moderating variable is often characterized statistically as an interaction. That is, a third variable that affects the direction and or strength of the relation between your explanatory and response variable. So, this type of exercise program affect the direction or strength of the relationship between diet and weight loss. The standard way of asking this question in the context of analysis of variance is to move to the use of a two-way or two-factor analysis of variance. Rather than the one-way or one-factor ANOVA that we've been using. Instead, we're gonna take a less standard approach that can be consistently used across each of the inferential tools. That is ANOVA, Chi Square, and Pearson Correlation. In each of these contexts, we're actually gonna be asking the question, is our explanatory variable associated with our response variable for each population subgroup or each level of our third variable? That is, are diet type and weight loss associated for those doing the cardio exercise program? And are diet and weight loss associated for those using the weight training program? To accomplish this, we're gonna run two separate ANOVAs, one for each level of the third variable, that is, for each exercise program. Syntax to be added to the general PROC ANOVA code is circled here in red. We need to first sort the data according to the categorical third variable, then include a by statement, telling Sass to run analysis of variance for each level of the third variable. The specific syntax for the diet and exercise example is shown here. In Sass, when we call in this example, diet and exercise data set, and run analysis of variance, you'll see the following results. The ANOVA table examining the relationship between diet and weight loss for those in the cardio exercise group shows a large F-value and a significant associated P-value. When examining the means table, we see that for those involved in the cardio exercise program, diet A is associated with greater weight loss 20.5 pounds on average, than diet B, which is 7.1 pounds on average. >> The association between diet and weight loss for those involved in the weight training exercise program is also significant. It has a large F-value. However, the means show that the association is in the opposite direction. For those involved in weight training, diet B is associated with greater weight loss, 11.5 pounds, compared to diet A, only 8.8 pounds. >> Here, these results are shown graphically. As you can see, the relationship between diet and weight loss depends on which exercise program is being used. When using cardio, diet A is significantly better for weight loss than diet B. When using weights, diet B is significantly better for weight loss than diet A. Thus, we can say there's a significant statistical interaction between the variables diet and weight loss. And the type of exercise, our third variable, moderates the association between diet and weigh loss. >> Suppose that we did not evaluate exercise as a possible moderator, and instead, focused only on the association between diet and weight loss for the entire population. Based on this graph, obviously, we would have incorrectly concluded that diet A is better than diet B. As we now know, that is only true if we're looking at the cardio group.