BookmarkSubscribeRSS Feed
greenie
Obsidian | Level 7

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?

 

 

6 REPLIES 6
StatDave
SAS Super FREQ

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;
greenie
Obsidian | Level 7

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;
PaigeMiller
Diamond | Level 26

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.

  • If there are errors in the log, show us the ENTIRE log for this PROC or DATA step
  • If the output is incorrect, show us the incorrect output and EXPLAIN why you think it is incorrect.
--
Paige Miller
greenie
Obsidian | Level 7
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

StatDave
SAS Super FREQ
PROC GLM does not support the PARAM= option in the CLASS statement. See the PROC GLM documentation anytime you get syntax errors. By default, the CLASS statement in PROC GLM will use 0,1 coding, so you do not need that option anyway. You will also need to remove the CL option from the MODEL statement.
greenie
Obsidian | Level 7

I got it. Thank you SO MUCH!

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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