is it away to do paired test with chi-square test?

Reply
Contributor
Posts: 67

is it away to do paired test with chi-square test?

Hi there,

I'm doing some analysis data. --- variables On_Med ( with 2 values Yes / No) and Med_code (with 6 levels A to F).

This is a frequency table looks like.

Med_code
On_MedABCDEFTOTAL
Yes2503501003004006002000
No502015352010150
TOTAL3003701153354206102150

I want to test the relationship between Mod_code A to B.versus On_med (Yes/No).

example: whether A has a relationship with B, C or B and E and so on.

is it possible to do with chi square? if it is, what is the code in SAS?

Any helps would very appreciate.

Thanks,

Respected Advisor
Posts: 2,655

Re: is it away to do paired test with chi-square test?

Check out PROC FREQ for an overall test of differences.  You will have to correctly shape your dataset:

data one;

input Med_code $ on_med $ wt;

datalines;

A yes 250

A no 50

B yes 350

B no 20

C yes 100

C no 15

D yes 300

D no 35

E yes 400

E no 20

F yes 600

F no 10

;

proc freq data=one;

tables med_code*on_med/all;

weight wt;

run;

All of the chi squared tests are significant (p<0.0001), so there is evidence of differences between the med_codes in whether individuals are on meds or not.

If you want pairwise comparisons, look into PROC LOGISTIC.

proc logistic data=one;

class med_code;

model on_med=med_code;

weight wt;

run;

This will give an overall test, as well as the odds ratios comparing each med_code to the last level of med_code.

Steve Denham

SAS Super FREQ
Posts: 3,630

Re: is it away to do paired test with chi-square test?

Steve made one tiny typo when he cut and pasted the code. You should use the FREQ statement in PROC LOGISTIC instead of the WEIGHT statement.  The statistics that Steve mentions are not affected by whether you use FREQ or WEIGHT, but other statistics treat weights and frequencies differently.

Respected Advisor
Posts: 2,655

Re: is it away to do paired test with chi-square test?

:smileyblush:  My bad.  I got carried away with cut and paste, and apologize to everyone.

Steve Denham

Contributor
Posts: 67

Re: is it away to do paired test with chi-square test?

Thank you very much for both of you!!

so to confirm the correct code:

proc logistic data=one;

class med_code;

model on_med=med_code;

Freq wt;

run;

is it correct?

Respected Advisor
Posts: 2,655

Re: is it away to do paired test with chi-square test?

Yes--that is what I should have posted.

Steve Denham

Ask a Question
Discussion stats
  • 5 replies
  • 503 views
  • 9 likes
  • 3 in conversation