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

Hi,

I run a chi-square test. My codes are below:

proc format;
value $category 
'' =''
'Agree'='Agree1'
'Disagree'= 'Disagree1'
'Neither agree or disagree'='Neither agree or disagree1'
'Strongly agree'= 'Agree1'
'Strongly disagree'= 'Disagree1'
;
proc freq data=red.survey2;
tables My_compensation_should_be_augmen*Program__select_one_ /chisq exact ;
format     My_compensation_should_be_augmen $category.  ;
run;

I received following output:

Table of My_compensation_should_be_augmen by Program__select_one_

My_compensation_should_be_augmen(My compensation should be augmented due to the associated risks)

Program__select_one_(Program: select one#)

Frequency
Percent
Row Pct
Col Pct

Anesthesia

Emergency Medicine

General Surgery

Total

Agree1

28
19.05
32.56
49.12

24
16.33
27.91
82.76

34
23.13
39.53
55.74

86
58.50


Disagree1

12
8.16
54.55
21.05

1
0.68
4.55
3.45

9
6.12
40.91
14.75

22
14.97


Neither agree or disagree1

17
11.56
43.59
29.82

4
2.72
10.26
13.79

18
12.24
46.15
29.51

39
26.53


Total

57
38.78

29
19.73

61
41.50

147
100.00

Frequency Missing = 4

 

Statistic

DF

Value

Prob

Chi-Square

4

10.0471

0.0396

Likelihood Ratio Chi-Square

4

11.1415

0.0250

Mantel-Haenszel Chi-Square

1

0.1559

0.6929

Phi Coefficient

 

0.2614

 

Contingency Coefficient

 

0.2529

 

Cramer's V

 

0.1849

 

 

 

I get a p-value of 0.0396.

This shows me that My_compensation_should_be_augmen is significantly different by the program.

However, it does not give me  what is specifically different here significantly.

I want to say something like respondents who agreed were significantly higher in Emergency Medicine than Anesthesia or may be respondents who agreed were significantly higher in Emergency Medicine than Anesthesia and Surgery. I am not sure which statement is correct.

How can i do that?

 

Thanks,

 

1 ACCEPTED SOLUTION

Accepted Solutions
Rick_SAS
SAS Super FREQ

There might be more than two numbers. It is the sum of the squared deviations that is important.

But to answer the spirit of your question, read the article "Color cells in a mosaic plot by deviation from independence," which shows how to create a mosaic plot in PROC FREQ that color-codes each cell according to the deviation from independence. 

tables X*Y / norow cellchi2 expected stdres crosslist
                           missing plots=MosaicPlot(colorstat=StdRes);

View solution in original post

5 REPLIES 5
Rick_SAS
SAS Super FREQ

When you perform a two-way frequency analysis, the syntax

tables X*Y / chisq;

performs a chi-square test for association between X and Y. The null hypothesis is that X and Y are independent. If the p-value is small, you reject the null hypothesis and conclude that there is an association between X and Y. See the section "Pearson Chi-Square Test for Two-Way Tables" in the PROC FREQ documentation.

Kyra
Quartz | Level 8

Thank you for the reply. How can I study which two numbers are statistically different in the Chi square analysis which is making two variables associated.

 

Thanks,

Rick_SAS
SAS Super FREQ

There might be more than two numbers. It is the sum of the squared deviations that is important.

But to answer the spirit of your question, read the article "Color cells in a mosaic plot by deviation from independence," which shows how to create a mosaic plot in PROC FREQ that color-codes each cell according to the deviation from independence. 

tables X*Y / norow cellchi2 expected stdres crosslist
                           missing plots=MosaicPlot(colorstat=StdRes);
Kyra
Quartz | Level 8
Thank you very much!
SteveDenham
Jade | Level 19

A couple of things to note.  You have 2 cells out of 9 where the counts are less than 5. Beware of using the standard chi squared test.  Your code calls for the exact option, so looking at the exact test results should inform you as to your next step.  Assuming you have identified that at least one column has a different association with the response variables than another.  You get 2 chances to test this, so you need to clearly identify what question you are trying to answer.  One way might be to ask: "Is anesthesia different from general surgery" and "Is EM different from general surgery". In this case, you have identified general surgery as a reference category. So you run follow-up analyses where you subset the data to include only anesthesia and general surgery in the first case and only EM and general surgery in the second case. Those are your 2 chances to test under the reference scenario.  Another scenario might be to test 1)Is the collapsed incidence of anesthesia and EM different from general surgery and 2)Is anesthesia different from EM?  What you shouldn't do is the all possible comparisons of anesthesia vs. general surgery, EM vs. general surgery, and anesthesia vs. EM.

So how do you go about this? The reference scenario can be done in two separate PROC FREQ calls, using a where= clause in the data= option to select the two columns of interest in each case. The second scenario involves some DATA step preprocessing to collapse the observations in two categories to a single category and then comparing the "collapsed" column to the third in one PROC FREQ call, and comparing the two categories involved in the collapse in a second PROC FREQ call.

 

SteveDenham

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 5 replies
  • 878 views
  • 5 likes
  • 3 in conversation