BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
bathshebat
Calcite | Level 5

How do you write a code in SAS that will enable you to calculate the odds ratio (OR) for a categorical variable such as BMI?

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

Your dataset only has one value for Exercise so you have 2X1 table?

 

You should really post sample data. 

 

Here's a worked through example of logistic regression that is really similar to what you're trying to do. 

http://www.ats.ucla.edu/stat/sas/dae/logit.htm

 

My only suggestion would be to change the model line to add the expb option.

 

model admit = gre gpa rank/expb;

expb provides the exponentiated value of the estimates

 

View solution in original post

8 REPLIES 8
Reeza
Super User

Depends a bit on what you're trying to do, but either proc freq or proc logistic are good starting points. 

 

If if you need more help, please post some sample data and explain what you're trying to calculate. 

The documentation has good examples and example data if you can't provide your actual data. 

bathshebat
Calcite | Level 5

Hi Reeza,

 

Thank you for your reply. I have a data set containing a variable called BMI (a categorical variable with 3 levels: normal, overweight and obese) and a variable called Exercise (a categorical variable with 3 levels: not answered, yes, and no). I want to determine which BMI group has the highest odds of not exercising. I am trying to compare the odds ratios for each group but the codes I have tried to run aren't producing the odds ratio. I have tried the following code to no avail:

 

data=answer2;

set answer;

if Exercise = 3;

run;

 

proc freq data=answer;

tables Exercise * BMI / OR;

run;

 

 

Ksharp
Super User

That is because your contingency table is 3x3 not 2x2 .

Try to use General Logistical Regression .

bathshebat
Calcite | Level 5

Thank you Xia. I will try that.

Reeza
Super User

Your dataset only has one value for Exercise so you have 2X1 table?

 

You should really post sample data. 

 

Here's a worked through example of logistic regression that is really similar to what you're trying to do. 

http://www.ats.ucla.edu/stat/sas/dae/logit.htm

 

My only suggestion would be to change the model line to add the expb option.

 

model admit = gre gpa rank/expb;

expb provides the exponentiated value of the estimates

 

bathshebat
Calcite | Level 5

@Reeza Thank you very much for your assistance. I am making progress. Lol.

ballardw
Super User

Any chance your data is from BRFSS or similar complex structured survey? If so you'll want to use Proc SurveyLogistic to use the sampling information correctly.

bathshebat
Calcite | Level 5

@ballardw Yes it is BRFSS data. I will try that as well. Thank you.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 8 replies
  • 1985 views
  • 2 likes
  • 4 in conversation