How can odds ratios be calculated in SAS, using an example? 2

How can odds ratios be calculated in SAS, using an example?

Odds ratios can be calculated in SAS through the use of the PROC LOGISTIC procedure. This procedure allows for the comparison of odds between different groups or categories within a dataset. For example, if we have a dataset with variables for gender and smoking status, we can use PROC LOGISTIC to calculate the odds ratio of smoking between males and females. This is done by fitting a logistic regression model and obtaining the odds ratio estimate from the “Odds Ratio” column in the output. The calculated odds ratio represents the likelihood of smoking for males compared to females. Overall, PROC LOGISTIC in SAS provides a reliable and efficient method for calculating odds ratios and analyzing relationships between categorical variables.

Calculate Odds Ratios in SAS (With Example)


In statistics, an odds ratio tells us the ratio of the odds of an event occurring in a treatment group compared to the odds of an event occurring in a control group.

We often calculate an odds ratio when performing an analysis on a 2-by-2 table, which takes on the following format:

To calculate an odds ratio in SAS, we can use the PROC FREQ statement.

The following example shows how to use this statement in practice.

Example: Calculating an Odds Ratio in SAS

Suppose 50 basketball players use a new training program and 50 players use an old training program. At the end of the program we test each player to see if they pass a certain skills test.

The following table shows the number of players who passed and failed, based on the program they used:

Suppose we would like to calculate an odds ratio to compare the odds of a player passing the skills test using the new program compared to using the old program.

We can use the following syntax with PROC FREQ in SAS with the chisq and relrisk statements to calculate this odds ratio along with relative risk values:

/*create dataset*/
data my_data;
    input result $ program $ count;
    datalines;
Passed New 34
Passed Old 39
_Failed New 16
_Failed Old 11
;
run;
/*calculate odds ratio*/
proc freqdata=my_data;
    weight count;
    tables program * result / chisqrelrisk;
run;

The first table in the output shows the frequency of each combination of the categorical variables:

The last table in the output shows the odds ratio that we’re interested in:

The odds ratio turns out to be 0.5994.

In other words, the odds that a player passes the test are actually lowered by about 40.06% by using the new program.

We can also use the values in the 95% confidence Limits columns of the output to construct the following 95% confidence interval for the odds ratio:

95% confidence interval for the odds ratio: [0.2449, 1.4666].

We are 95% confident that the true odds ratio between the new and old training program is contained in this interval.

Since the confidence interval contains the odds ratio value of 1, it means the odds ratio is not statistically significant.

In other words, we know from the odds ratio that the odds of a player passing using the new program are lower than the odds of passing using the old program, but the difference between these odds is not actually statistically significant.

The following tutorials provide additional information about odds ratios:

Cite this article

stats writer (2024). How can odds ratios be calculated in SAS, using an example?. PSYCHOLOGICAL SCALES. Retrieved from https://scales.arabpsychology.com/stats/how-can-odds-ratios-be-calculated-in-sas-using-an-example/

stats writer. "How can odds ratios be calculated in SAS, using an example?." PSYCHOLOGICAL SCALES, 23 Jun. 2024, https://scales.arabpsychology.com/stats/how-can-odds-ratios-be-calculated-in-sas-using-an-example/.

stats writer. "How can odds ratios be calculated in SAS, using an example?." PSYCHOLOGICAL SCALES, 2024. https://scales.arabpsychology.com/stats/how-can-odds-ratios-be-calculated-in-sas-using-an-example/.

stats writer (2024) 'How can odds ratios be calculated in SAS, using an example?', PSYCHOLOGICAL SCALES. Available at: https://scales.arabpsychology.com/stats/how-can-odds-ratios-be-calculated-in-sas-using-an-example/.

[1] stats writer, "How can odds ratios be calculated in SAS, using an example?," PSYCHOLOGICAL SCALES, vol. X, no. Y, ص Z-Z, June, 2024.

stats writer. How can odds ratios be calculated in SAS, using an example?. PSYCHOLOGICAL SCALES. 2024;vol(issue):pages.

Download Post (.PDF)
Slide Up
x
PDF
Scroll to Top