turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- Analytics
- /
- Stat Procs
- /
- calculating the OR for Categorical Variables

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

04-07-2016 07:29 PM

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?

Accepted Solutions

Solution

04-09-2016
09:03 PM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

04-07-2016 11:28 PM

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

All Replies

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

04-07-2016 07:40 PM

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.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

04-07-2016 10:29 PM

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;

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

04-07-2016 10:55 PM

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

Try to use General Logistical Regression .

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

04-09-2016 09:01 PM

Thank you Xia. I will try that.

Solution

04-09-2016
09:03 PM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

04-07-2016 11:28 PM

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

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

04-09-2016 09:04 PM

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

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

04-08-2016 11:09 AM

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.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

04-09-2016 09:02 PM

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