Hi all,
I have a question on how to code an interaction for my data.
My aim is to know the interaction of diet (continuous variable) and physical activity (categorical variable, three levels: low, mod, high) on T2DM and inflammatory markers. I want to set physical activity "low" as reference so that I can see the comparison of "mod" to "low", and "high" to "low".
For the logistic regression model on T2DM, should I set physical activity as dummy variables and write the code as:
data mydata; set mydata; if IPAQ= 1 then low = 1; else low=0; if IPAQ= 2 then mod = 1; else mod=0; if IPAQ = 3 then high = 1; else high=0; run;
proc logistic data = mydata; class mod high/ ref=first; model T2DM (event = '1') = diet mod high diet*mod diet*high confounders/ cl; run;
Or should I write the logistic regression model separately, like, for mod:
proc logistic data = mydata; class mod / ref=first; model T2DM (event = '1') = diet mod diet*mod confounders/ cl; run;
and for high:
proc logistic data = mydata; class high/ ref=first; model T2DM (event = '1') = diet high diet*high confounders/ cl; run;
I'm not sure which statistical method is correct.
Can anyone help me?
You should use your original, three-level variable in the CLASS statement. The CLASS statement is there to create dummy variables for you, so there is no need to create them yourself. Use PARAM=REF (or GLM) to use the typical 0,1 coding.
proc logistic data = mydata;
class IPAQ / ref=first param=ref;
model T2DM (event = '1') = diet IPAQ diet*IPAQ confounders/ cl;
run;
Thank you! So when for the glm statement for inflammatory markers as outcome, this code with class statement seemed not work...Do you have any suggestion on dealing this?
proc glm data = mydata; class IPAQ / ref=first param=ref; model IL8 = diet IPAQ diet*IPAQ confounders/ cl; run;
Don't say something didn't work, and then give us no further information about what didn't work.
Give us information about what didn't work.
99 proc glm data = mydata; 100 class IPAQ/ ref=first param=ref; ----- 22 202 NOTE: The previous statement has been deleted. ERROR 22-322: Syntax error, expecting one of the following: ;, REF, REFERENCE, TRUNCATE. ERROR 202-322: The option or parameter is not recognized and will be ignored. 101 model IL8 =diet IPAQ diet*IPAQ age BMI/ cl; -- 22 202 NOTE: The previous statement has been deleted. ERROR 22-322: Syntax error, expecting one of the following: ;, ALIASING, ALPHA, CLI, CLM, CLPARM, COVBYCLASS, E, E1, E2, E3, E4, EST, I, INTERCEPT, INVERSE, NOINT, NOUNI, P, PREDICTED, SINGULAR, SOLUTION, SS1, SS2, SS3, SS4, TOLERANCE, X, XPX, ZETA. ERROR 202-322: The option or parameter is not recognized and will be ignored. 102 run;
Please see this
I got it. Thank you SO MUCH!
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.