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

Hi everyone,

 

I need some help on Cochran-Mantel-Haenszel test (SAS Studio) in calculating the

1) the row mean score differ and

2) the general association for a set of data. (shown below) 

 

Score      below average     average        above average

Class X       1                     9              20

Class Y        3                    22             5

Class G       2                     3              25

 

New to SAS, so every answer would be appreciated.

 

Thanks,

@Sam20.

1 ACCEPTED SOLUTION

Accepted Solutions
FreelanceReinh
Jade | Level 19

Hi @Sam20 and welcome to the SAS Support Communities!

 

The first step is to create a SAS dataset from the raw data (if not already done). The statistical tests will be done with PROC FREQ (see Example 46.7 Cochran-Mantel-Haenszel Statistics in the documentation). If the structure of the initial SAS dataset is not suitable for this procedure, you need to adapt it in an intermediate step.

 

Example:

/* Read raw data into SAS */

data have;
input class $7. below_av average above_av;
cards;
Class X  1   9  20
Class Y  3  22   5
Class G  2   3  25
;

/* Create input dataset for PROC FREQ */

proc transpose data=have name=score out=want(rename=(col1=n));
by class notsorted;
run;

/* Compute Cochran-Mantel-Haenszel statistics */

proc freq data=want;
label score=' ';
weight n;
tables class*score / cmh;
run;

 

 

View solution in original post

1 REPLY 1
FreelanceReinh
Jade | Level 19

Hi @Sam20 and welcome to the SAS Support Communities!

 

The first step is to create a SAS dataset from the raw data (if not already done). The statistical tests will be done with PROC FREQ (see Example 46.7 Cochran-Mantel-Haenszel Statistics in the documentation). If the structure of the initial SAS dataset is not suitable for this procedure, you need to adapt it in an intermediate step.

 

Example:

/* Read raw data into SAS */

data have;
input class $7. below_av average above_av;
cards;
Class X  1   9  20
Class Y  3  22   5
Class G  2   3  25
;

/* Create input dataset for PROC FREQ */

proc transpose data=have name=score out=want(rename=(col1=n));
by class notsorted;
run;

/* Compute Cochran-Mantel-Haenszel statistics */

proc freq data=want;
label score=' ';
weight n;
tables class*score / cmh;
run;

 

 

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 1 reply
  • 945 views
  • 4 likes
  • 2 in conversation