10-09-2014 09:32 PM
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;
tables freq_b4 / binomial(level=1 p=0.05 );
tables freq_b4 / binomial(level=10 p=0.1 );
10-10-2014 09:30 PM
Thanks for your reply.
My data looks like this. The sample size is small with only about 100 individuals.
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
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 .
10-11-2014 10:33 PM
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
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.
10-13-2014 09:10 AM
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.
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) .
Message was edited by: xia keshan
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.