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

Why can't SAS compute McNemar's test when zeros are in a column? I think that it is because SAS doesn't "know" that there are zeros.

For example, consider the following data set for a hypothetical case-control study.

data one;
	input caseevent controlevent number;
	cards;
	0 0 0
	0 1 9
	1 0 0
	1 1 15
	;
run;

In this data set, controls are matched to cases. We have 0 case-control pairs where both the case and the control do NOT have the event.

There are 15 pairs where they both have the case.

For discordant pairs, we have 9 instances where the control had an event, and the case did not.

Also, we have 0 instances where the case had an event, and the case did not.

 

Running PROC FREQ and requesting McNemar test:

proc freq data=one;
	tables caseevent*controlevent / agree;
	weight number;
	exact mcnemar;
run;

We get the appropriate table

image.png

 

But, there is no McNemar test and SAS log gives a NOTE:

Capture.PNG

 

So, apparently SAS thinks we are missing data.

I can calculate McNemar test (with or without continuity correction) manually. In this case X2=(|9-0|^2)/9=9 with one degree of freedom.

Or continuity corrected X2=((|9-0|-1)^2)/9=7.1.

 

But, it there some way to get sas to do this without having to program it? Further, I would prefer the Exact McNemar test. But, maybe I just need to program conditional Binomial tests for this.

1 ACCEPTED SOLUTION

Accepted Solutions
SAS_Rob
SAS Employee

You will need to add the ZEROS option to the WEIGHT statement.

proc freq data=one;
tables caseevent*controlevent / agree;
weight number/zeros;
exact mcnemar;
run;

View solution in original post

3 REPLIES 3
SAS_Rob
SAS Employee

You will need to add the ZEROS option to the WEIGHT statement.

proc freq data=one;
tables caseevent*controlevent / agree;
weight number/zeros;
exact mcnemar;
run;

cminard
Obsidian | Level 7

Thanks, did not know about the zero option. I suppose that if I have raw data, then this is not going to work. I would have to count the observations in each cell first and create a data set with these summary statistics (frequencies). Then, I could use the zero option with the weighted statement.

SAS_Rob
SAS Employee

Yes, with raw data you could assign a count of 1 to each observation and then add an observation with the missing row/column combination and a count of 0.

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
  • 3 replies
  • 4191 views
  • 6 likes
  • 2 in conversation