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
- /
- difference in proportions

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

10-09-2014 09:32 PM

Dear all,

I wish you all well.

I have two(freq_b4 and freq_after) 10-level category variables which I would like to test if the proportions of each level from the 2 variables differ.

Am I doing it right? Your insight is greatly appreciated.

My SAS code is as below:

proc freq data=tmp compress;

exact binomial;

tables freq_b4 / binomial(level=1 p=0.05 );

.

.

.

tables freq_b4 / binomial(level=10 p=0.1 );

run;

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

10-10-2014 08:39 AM

What does your data look like ?

And better post it at SAS Statistical Procedures

Let more statistical expert to see it .

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

10-10-2014 09:30 PM

Hi Keshan.

Thanks for your reply.

My data looks like this. The sample size is small with only about 100 individuals.

id | freq_before | freq_after |
---|---|---|

1 | 10 | 1 |

2 | 5 | 2 |

3 | 6 | 8 |

. . . | . . . | . . . |

100 | 2 | 3 |

where 10=everyday, 9=once every few days, ...., 1=never for both freq_before and freq_after variable.

I was wondering if I should create dummy variables for the two 10-level categorical variables and do a Chi-square test/Fisher's exact test like this? :smileyconfused:

proc freq data=tmp; tables before_level1*after_level1 / chisq; run;

.

.

.

proc freq data=tmp; tables before_level10*after_level10 / chisq; run;

Any comments and insight is greatly appreciated

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

10-11-2014 08:45 AM

"I was wondering if I should create dummy variables for the two 10-level categorical variables and do a Chi-square test/Fisher's exact test like this?"

Why do you need to create a dummy variable ? Yes. I think you can do a Chi-square test/Fisher's exact test ,better Fisher's exact test, since you have so many levels and so few obs , there are might lots of cells have < 5 obs .

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

10-11-2014 10:33 PM

Hi Keshan.

Thanks for your reply.

Actually, maybe I need to do a McNemar's due to the correlated proportions of before and after from individuals.

I thought I need to create dummy variables for the two 10-level categorical variables in order to test for the before and after proportion for each level.

If I just did a Fisher's exact test between the two 10-level freq_before and 10-level freq_after variable, it will not tell me which level of before and after proportions are different.

Am I making any sense here? :smileyconfused:

Any comment and insight is greatly appreciated

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

10-12-2014 08:22 AM

"maybe I need to do a McNemar's due to the correlated proportions of before and after from individuals."

If I was right, McNemar test is only for 2*2 contingency table .

Not sure ,Maybe you should try Proc logistic .

And don't forget to

post it at SAS Statistical Procedures

Doc Steve might have a good vision.

Xia Keshan

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

10-12-2014 08:48 AM

Hi Keshan.

Thanks for your reply.

By the way, I thought I've already moved this post to SAS Statistical Procedures. Have I not? :smileyconfused:

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

10-13-2014 09:10 AM

Hi,

Maybe you could try one-way probability test by proc freq. But since there are 10 levels for each two variables, that could be 10*10 levels totally for your data .that is to say your data is too sparse for each levels.

E.X.

take sashelp.class as an example. we want to test if Female and Male have the same proportion . in other words , Test H0: F=0.5 and M=0.5 , now we can code like :

proc freq data=sashelp.class; tables sex/nocum chisq testp=(50 50); exact fisher ; run; Chi-Square Test for Specified Proportions ------------------------- Chi-Square 0.0526 DF 1 Pr > ChiSq 0.8185 Sample Size = 19

Now see the P-value is 0.8 . We have no reason to reject H0 . (i.e. Female and Male have the same proportion) .

Xia Keshan

Message was edited by: xia keshan

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

10-15-2014 08:11 AM

Hello K C,

If you have SAS/STAT13.2, you can get Bowker's test output (generalization of McNemar's test to 2xK tables) with:

proc freq data=tmp;

tables before_level10*after_level10 / agree; run;

I can't guarantee this is what you are looking for, but it is now available.

Steve Denham