Is it even possible to do in sas studio?
If I know all the numbers in the two by two table of a case-control study. Could sas calculate the percentages of each number and the odds ratio? Thank you.
Just type the counts in. Make sure you also create the other two variables.
data summary;
length group result $8 count 8;
do group='case','control';
do result='good','bad';
input count @@;
output;
end;
end;
cards;
10 50 49 11
;
proc freq;
tables group*result / cmh ;
weight count;
run;
The FREQ Procedure Table of group by result group result Frequency| Percent | Row Pct | Col Pct |bad |good | Total ---------+--------+--------+ case | 50 | 10 | 60 | 41.67 | 8.33 | 50.00 | 83.33 | 16.67 | | 81.97 | 16.95 | ---------+--------+--------+ control | 11 | 49 | 60 | 9.17 | 40.83 | 50.00 | 18.33 | 81.67 | | 18.03 | 83.05 | ---------+--------+--------+ Total 61 59 120 50.83 49.17 100.00 The FREQ Procedure Summary Statistics for group by result Cochran-Mantel-Haenszel Statistics (Based on Table Scores) Statistic Alternative Hypothesis DF Value Prob --------------------------------------------------------------- 1 Nonzero Correlation 1 50.2915 <.0001 2 Row Mean Scores Differ 1 50.2915 <.0001 3 General Association 1 50.2915 <.0001 Common Odds Ratio and Relative Risks Statistic Method Value 95% Confidence Limits ------------------------------------------------------------------------------------- Odds Ratio Mantel-Haenszel 22.2727 8.6773 57.1693 Logit 22.2727 8.6773 57.1693 Relative Risk (Column 1) Mantel-Haenszel 4.5455 2.6333 7.8462 Logit 4.5455 2.6333 7.8462 Relative Risk (Column 2) Mantel-Haenszel 0.2041 0.1145 0.3639 Logit 0.2041 0.1145 0.3639 Total Sample Size = 120
You will need to create a small dataset with three columns: 1. columns values 2. row values, 3 cell counts. For a 2x2 table you will have four rows with all possible combinations of row and column values: 00, 01, 10, 11. Then run PROC FREQ with WEIGHT as cell counts. That's it.
Just type the counts in. Make sure you also create the other two variables.
data summary;
length group result $8 count 8;
do group='case','control';
do result='good','bad';
input count @@;
output;
end;
end;
cards;
10 50 49 11
;
proc freq;
tables group*result / cmh ;
weight count;
run;
The FREQ Procedure Table of group by result group result Frequency| Percent | Row Pct | Col Pct |bad |good | Total ---------+--------+--------+ case | 50 | 10 | 60 | 41.67 | 8.33 | 50.00 | 83.33 | 16.67 | | 81.97 | 16.95 | ---------+--------+--------+ control | 11 | 49 | 60 | 9.17 | 40.83 | 50.00 | 18.33 | 81.67 | | 18.03 | 83.05 | ---------+--------+--------+ Total 61 59 120 50.83 49.17 100.00 The FREQ Procedure Summary Statistics for group by result Cochran-Mantel-Haenszel Statistics (Based on Table Scores) Statistic Alternative Hypothesis DF Value Prob --------------------------------------------------------------- 1 Nonzero Correlation 1 50.2915 <.0001 2 Row Mean Scores Differ 1 50.2915 <.0001 3 General Association 1 50.2915 <.0001 Common Odds Ratio and Relative Risks Statistic Method Value 95% Confidence Limits ------------------------------------------------------------------------------------- Odds Ratio Mantel-Haenszel 22.2727 8.6773 57.1693 Logit 22.2727 8.6773 57.1693 Relative Risk (Column 1) Mantel-Haenszel 4.5455 2.6333 7.8462 Logit 4.5455 2.6333 7.8462 Relative Risk (Column 2) Mantel-Haenszel 0.2041 0.1145 0.3639 Logit 0.2041 0.1145 0.3639 Total Sample Size = 120
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.