I'm currently working on a project using NHANES data looking at Chlamydia status as my outcome measure and bmi and various sexual behaviors as my exposures. Im needing to run 2 interaction models 1) bmi(has 4 levels) and gender (has 2 levels) 2) bmi(has 4 levels) and new sexual partner in the past 12 months (has 2 levels). I've only ever ran interaction models using proc logistic and SAS lets you easily make the interaction terms in the model statement however proc surveylogisitc doesnt let you do this. I've done some dummy coding to make the variables but am not sure if what I did was correct.
Just for reference:
VALUE UNDERF
1= 'FEMALE-UNDER'
0= 'MALE-HEALTHY';
VALUE BMI
1 = 'UNDERWEIGHT (<5TH PERCENTILE)'
2 = 'HEALTHY WEIGHT (5TH TO <85TH PERCENTILE)'
3 = 'OVERWEIGHT (85TH TO <95TH PERCENTILE)'
4 = 'OBESE (95TH PERCENTILE AND ABOVE'
. = 'MISSING';
I dummy coded one of my levels for gender and bmi like this:
*underwieght and being female);
UNDERF=.;
IF GENDER=1 AND BMI=1 THEN UNDERF=1;
ELSE IF GENDER=0 AND BMI=2 THEN UNDERF=0; *healthy male is my reference category;
ELSE UNDERF=.;
Am i on the right track with my dummy coding the interaction terms? I would then just insert each individual term into the model to get my interaction ORs. If I'm on the right track witht that I need helping getting my p value for the overall group. Since I'm doing each level individually is there an easy way to get the overall group p value so i can compare the significance of the model with and without the interaction terms? If I cant do it as is how do i go about getting that p value?
I'm currently working on a project using NHANES data looking at Chlamydia status as my outcome measure and bmi and various sexual behaviors as my exposures. Im needing to run 2 interaction models 1) bmi(has 4 levels) and gender (has 2 levels) 2) bmi(has 4 levels) and new sexual partner in the past 12 months (has 2 levels). I've only ever ran interaction models using proc logistic and SAS lets you easily make the interaction terms in the model statement however proc surveylogisitc doesnt let you do this. I've done some dummy coding to make the variables but am not sure if what I did was correct.
Just for reference:
VALUE UNDERF
1= 'FEMALE-UNDER'
0= 'MALE-HEALTHY';
VALUE BMI
1 = 'UNDERWEIGHT (<5TH PERCENTILE)'
2 = 'HEALTHY WEIGHT (5TH TO <85TH PERCENTILE)'
3 = 'OVERWEIGHT (85TH TO <95TH PERCENTILE)'
4 = 'OBESE (95TH PERCENTILE AND ABOVE'
. = 'MISSING';
I dummy coded one of my levels for gender and bmi like this:
*underwieght and being female);
UNDERF=.;
IF GENDER=1 AND BMI=1 THEN UNDERF=1;
ELSE IF GENDER=0 AND BMI=2 THEN UNDERF=0; *healthy male is my reference category;
ELSE UNDERF=.;
Am i on the right track with my dummy coding the interaction terms? I would then just insert each individual term into the model to get my interaction ORs. If I'm on the right track witht that I need helping getting my p value for the overall group. Since I'm doing each level individually is there an easy way to get the overall group p value so i can compare the significance of the model with and without the interaction terms? If I cant do it as is how do i go about getting that p value?
I'm confused.
SURVEYLOGISTIC supports both CLASS variables and interaction terms as far as I see. Is there some other reason it's not working?
Can you post what your code looks like so far?
Ideally, if you can mock up some fake data to work with and replicate your issue that would be great. SASHELP.HEART may be a good place to start, if you need fake data.
I was told that surveylogistic doesnt intuitively read the interaction terms like proc logistic does. In proc logisitc ii can easily put an interaction term by just putting bmi*gender and then ask for the oddsratio. I cant do that in proc surveylogisitc or at least thats what I was told, right?
Interesting....who told you this?
I can't see a technical reason, there may be a statistical reason but that's beyond me for logistic regression. We'll have to wait for someone with more statistical expertise comments - you can also ask tech support.
I was told by a professor and even tried it myself and SAS automatically set my interaction term to 0 when i tried and didnt output an odds ratio for the term.. I'm not sure why though
It doesn't default the oddsratio for sure, still not sure about interaction term. Not all professors keep up with software, but s/he may be correct.
Show your original code, without the manual dummy coding, that you say results in all 0.
If you specified it correctly that shouldn't happen IMO.
@vcvarela wrote:
I'm currently working on a project using NHANES data looking at Chlamydia status as my outcome measure and bmi and various sexual behaviors as my exposures. Im needing to run 2 interaction models 1) bmi(has 4 levels) and gender (has 2 levels) 2) bmi(has 4 levels) and new sexual partner in the past 12 months (has 2 levels).
I've only ever ran interaction models using proc logistic and SAS lets you easily make the interaction terms in the model statement however proc surveylogisitc doesnt let you do this. I've done some dummy coding to make the variables but am not sure if what I did was correct.
Can you provide an example of what you attempted that prompted the statement in red above. Code and any messages from the log would be helpful. Also which version of SAS are you running? There was a bug in an earlier version that had issues with Survey proc and interaction terms.
I'm not sure why that text is showing up red for you? I didnt type it in red and looking at my post now there is no red text.
I'm used to making an interaction model like this using proc logistic:
MODEL CHLAMYDIA (DESCENDING) = AGE NEW_12M RACE LIFETIME_SEX SEX_12M PAST_CHLAP UNPRO_12M bmi gender bmi*gender
Although, I was told that proc surveylogistic doesnt have that capability and even when i tried it SAS set all values for the interaction term bmi*gender to 0. So I decided to dummy code interaction variables by simply combining my 2 variables of interest for the interaction models like this where 0 for each dummy variable is my reference:
UNDERF=.;
IF GENDER=1 AND BMI=1 THEN UNDERF=1;
ELSE IF GENDER=0 AND BMI=2 THEN UNDERF=0;
ELSE UNDERF=.;
UNDERM=.;
IF GENDER=0 AND BMI=1 THEN UNDERM=1;
ELSE IF GENDER=0 AND BMI=2 THEN UNDERM=0;
ELSE UNDERM=.;
HEALTHF=.;
IF GENDER=1 AND BMI=2 THEN HEALTHF=1;
ELSE IF GENDER=0 AND BMI=2 THEN HEALTHF=0;
ELSE HEALTHF=.;
OVERF=.;
IF GENDER=1 AND BMI=3 THEN OVERF=1;
ELSE IF GENDER=0 AND BMI=2 THEN OVERF=0;
ELSE OVERF=.;
OVERM=.;
IF GENDER=0 AND BMI=3 THEN OVERM=1;
ELSE IF GENDER=0 AND BMI=2 THEN OVERM=0;
ELSE OVERM=.;
OBESEF=.;
IF GENDER=1 AND BMI=4 THEN OBESEF=1;
ELSE IF GENDER=0 AND BMI=2 THEN OBESEF=0;
ELSE OBESEF=.;
OBESEM=.;
IF GENDER=0 AND BMI=4 THEN OBESEM=1;
ELSE IF GENDER=0 AND BMI=2 THEN OBESEM=0;
ELSE OBESEM=.;
and then enter each of those dummy coded interaction variables into my model individually like this:
PROC SURVEYLOGISTIC
DATA=NO_MISSING;
WEIGHT WTMEC2YR;
STRATUM SDMVSTRA;
CLUSTER SDMVPSU;
CLASS
RACE (REF='NON-HISPANIC WHITE')
UNPRO_12M (REF='NEVER')
BMI (REF='HEALTHY WEIGHT (5TH TO <85TH PERCENTILE)')
NEW_12M (REF="NO")
GENDER (REF='MALE')
PAST_CHLAP (REF='NO')
AGE(REF='30-34')
UNDERM (REF='MALE-HEALTHY')
/PARAM=REF;
MODEL CHLAMYDIA (DESCENDING) = AGE NEW_12M RACE LIFETIME_SEX SEX_12M PAST_CHLAP UNPRO_12M UNDERM;
FORMAT
UNDERM UNDERM.
NEW_12M NEW_12M.
GENDER GENDER.
RACE RACE.
BMI BMI.
PAST_CHLAP PAST_CHLAP.
UNPRO_12M UNPRO_12M.
AGE AGE.;
TITLE 'INTERACTION MODEL BMI AND GENDER';
RUN;
I just wanted to check to see if im on the right track with dummy coding in order to study my interactions of interest or if there was an easier way?
Im using SAS 9.4
@vcvarela wrote:
I'm not sure why that text is showing up red for you? I didnt type it in red and looking at my post now there is no red text.
I highlighted the text in red to indicate what needed some explanation or expansion.
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.