BookmarkSubscribeRSS Feed
jjjjvvvv0000
Calcite | Level 5

Hello,

 

I am not sure if I am coding this correctly. I am assessing the odds that someone receives a second dose of vaccine depending on the type of clinic they went to for their first dose. Would someone mind reviewing my code to let me know if the way I have it written makes sense?

 

SecondDose is categorical as either "Yes" or "No". Yes means the person got a second dose. No means they did not.

CLINIC_TYPE is categorical as either "1" or "2" for two different clinic types.

RECIP_SEX is categorical as M, F, or U, but I included a where statement to remove U (I think...?)

RECIP_RACE_ETH is also categorical (e.g., White, Black, etc.)

RECIP_AGE is continuous.

 

I want to get the adjusted OR of getting a second dose at clinic type 1 vs. clinic type 2 for each race/ethnicity (i.e., RECIP_RACE_ETH) category while controlling for the continuous variable Age (RECIP_AGE) and the categorical variable Sex (RECIP_SEX).

 

proc sort data=vaccine;
by RECIP_RACE_ETH;
run;

 

proc logistic data=vaccine;
   class SecondDose CLINIC_TYPE (Ref = '1') RECIP_SEX  RECIP_RACE_ETH / param=ref;
   model SecondDose (event = "Yes") = CLINIC_TYPE RECIP_AGE RECIP_SEX RECIP_RACE_ETH;
   where RECIP_SEX = "M" or RECIP_SEX = "F";
   by RECIP_RACE_ETH;
run;

 

Thanks in advance for your help.

7 REPLIES 7
StatDave
SAS Super FREQ

You definitely don't want to put a variable in the BY statement in the MODEL statement since then it will only have one value and therefore no variability in each BY group analysis. If you want your odds ratios adjusted for sex, race, and age, then put them all in the model and don't use the BY statement. You also don't need to specify the response variable in the CLASS statement. So, these statements should provide a table including an estimate of the odds ratio that compares the two clinics. Note that since you include no interactions in your model, you are assuming that the odds ratio does not change within different levels of the other variables.

proc logistic data=vaccine;
   class CLINIC_TYPE (Ref = '1') RECIP_SEX  RECIP_RACE_ETH / param=ref;
   model SecondDose (event = "Yes") = CLINIC_TYPE RECIP_AGE RECIP_SEX RECIP_RACE_ETH;
   where RECIP_SEX = "M" or RECIP_SEX = "F";
   run;
jjjjvvvv0000
Calcite | Level 5

Thanks for your response.

 

The reason I included the BY statement was to run the aORs BY RECIP_SEX for example to see what the aOR would be for Male ("M") or Female ("F") while adjusting for the other variables. Is that not the correct way to do that?

 

For example, here is the output when RECIP_SEX = "F"

jjjjvvvv0000_0-1703187036088.png

 

My other question is, for RECIP_RACE_ETH, if I want to control for RECIP_RACE_ETH, should it be comparing each race to vs White? Or is there another way to do this?

StatDave
SAS Super FREQ
Before, you had your race variable in the BY statement, not your sex variable. In any case, if you want to obtain one odds ratio estimate for the clinic effect that is adjusted for sex, race, and age, then you need a single model that includes all of those variables; not separate models by sex (or race). The code I showed before provides that. Otherwise, if you have your sex variable in a BY statement, then you'll get two analyses with two estimates of the clinic effect. If you want that, it is better to do it with a single model that includes the clinic*sex interaction, not with a BY statement. With the interaction in the model, you would include an ODDSRATIO statement:
oddsratio clinic;
jjjjvvvv0000
Calcite | Level 5

Hi Dave,

Thanks again. I think the confusion I'm having is that I am comparing the likelihood of return for a second dose by clinic type within each group. For example, I want the odds of returning for a second dose at clinic type 1 vs. 2 for Sex = "M" as well as for Sex = "F", etc. while controlling for other variables. When I run the code you provided, I am getting ORs that are comparing to other groups (i.e., M vs. F). How can I correct the code to test within group while controlling for other variables vs. comparing to other groups?

 

ORs that results in something like this:

jjjjvvvv0000_0-1703195733663.png

i.e., comparing Clinic 1 vs. Clinic 2 for Male (or "M") and then separately for Female (or "F"), etc.

StatDave
SAS Super FREQ

As I said, your model does not allow for the odds ratio comparing clinics to change by sex (or race or age). To allow the model to estimate different clinic odds ratios for the two sexes you need to include the clinic*sex interaction as shown in the following statements. The LSMEANS statement provides the estimated event probability for each clinic-sex combination (in the Mean column). The ODDSRATIO statement provides the odds ratio estimates comparing clinics in each sex level.

proc logistic data=vaccine;
   class CLINIC_TYPE (Ref = '1') RECIP_SEX  RECIP_RACE_ETH / param=glm;
   model SecondDose (event = "Yes") = CLINIC_TYPE|RECIP_SEX RECIP_AGE RECIP_RACE_ETH;
   lsmeans CLINIC_TYPE*RECIP_SEX / ilink cl;
   oddsratio CLINIC_TYPE;
   where RECIP_SEX = "M" or RECIP_SEX = "F";
   run;
jjjjvvvv0000
Calcite | Level 5

Okay, got it, this works great.

 

Last question for you: if I am also wanting the ORs for different races/ethnicities (e.g., White, Black, Hispanic), would I need to run a separate proc logistic code using RECIP_RACE_ETH or can I also add in a RECIP_RACE_ETH interaction into the same model?

 

Thanks again.

StatDave
SAS Super FREQ

Just add the clinic*race interaction in the MODEL and LSMEANS statements. But you'll notice in the ODDSRATIO results that now the clinic effect depends on both sex and race. If you want clinic odds ratios for sex alone then you can ignore any variability over race. Similarly for the clinic odds ratio for race alone. That can be done using SLICE statements and the ODDSRATIO option.

   model SecondDose (event = "Yes") = CLINIC_TYPE|RECIP_SEX RECIP_AGE CLINIC_TYPE|RECIP_RACE_ETH;
   oddsratio CLINIC_TYPE;
   slice CLINIC_TYPE*RECIP_SEX / sliceby=RECIP_SEX diff cl oddsratio;
   slice CLINIC_TYPE*RECIP_RACE_ETH / sliceby=RECIP_RACE_ETH diff cl oddsratio;

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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
  • 7 replies
  • 2011 views
  • 2 likes
  • 2 in conversation