Output Data Set of Frequencies

data Color;
      input Region Eyes $ Hair $ Count @@;
         label Eyes  ='Eye Color'
               Hair  ='Hair Color'
               Region='Geographic Region';
         datalines;
1 blue  fair   23  1 blue  red     7  1 blue  medium 24
1 blue  dark   11  1 green fair   19  1 green red     7
1 green medium 18  1 green dark   14  1 brown fair   34
1 brown red     5  1 brown medium 41  1 brown dark   40 
1 brown black   3  2 blue  fair   46  2 blue  red    21
2 blue  medium 44  2 blue  dark   40  2 blue  black   6
2 green fair   50  2 green red    31  2 green medium 37
2 green dark   23  2 brown fair   56  2 brown red    42
2 brown medium 53  2 brown dark   54  2 brown black  13
;
run;

proc freq data=Color;
    tables Eyes Hair Eyes*Hair / out=FreqCount outexpect sparse;
    weight Count;
    title 'Eye and Hair Color of European Children';
run;

   
proc print data=FreqCount noobs;
    title2 'Output Data Set from PROC FREQ';
run;

/***********************Frequency Dot Plots*************************/

ods graphics on;
proc freq data=Color order=freq;
    tables Hair Eyes*Hair / plots=freqplot(type=dot);
    tables Region*Hair / plots=freqplot(type=dot scale=percent);
    weight Count;
  title "***********************Frequency Dot Plots*************************";
    title2 'Eye and Hair Color of European Children';
run;
ods graphics off;

/***********************Chi-Square Goodness-of-Fit Tests************************/

proc sort data=Color;
    by Region;
run;
   
ods graphics on;
proc freq data=Color order=data;
    tables Hair / nocum chisq testp=(30 12 30 25 3)
                  plots(only)=deviationplot(type=dot);
    weight Count;
    by Region;
    title "***********************Chi-Square Goodness-of-Fit Tests************************";
  title2 'Hair Color of European Children';                
run;
ods graphics off;

/************************Binomial Proportions************************/

proc freq data=Color order=freq;
    tables Eyes / binomial(ac wilson exact) alpha=.1;
    tables Hair / binomial(equiv p=.28 margin=.1);
    weight Count;
  title "************************Binomial Proportions************************";
    title2 'Hair and Eye Color of European Children';
run;

/************************Analysis of a 2x2 Contingency Table*************************/

proc format;
    value ExpFmt 1='High Cholesterol Diet'
                 0='Low Cholesterol Diet';
    value RspFmt 1='Yes'
                 0='No';
run;

   
data FatComp;
      input Exposure Response Count;
      label Response='Heart Disease';
      datalines;
0 0  6
0 1  2
1 0  4
1 1 11
;

   
proc sort data=FatComp;
    by descending Exposure descending Response;
run;

proc freq data=FatComp order=data;
    format Exposure ExpFmt. Response RspFmt.;
    tables Exposure*Response / chisq relrisk;
    exact pchi or;
    weight Count;
  title "************************Analysis of a 2x2 Contingency Table*************************";
    title2 'Case-Control Study of High Fat/Cholesterol Diet';
run;

/*************************Output Data Set of Chi-Square Statistics*************************/

proc freq data=Color order=data;
    tables Eyes*Hair / expected cellchi2 norow nocol chisq;
    output out=ChiSqData n nmiss pchi lrchi;
    weight Count;
  title "*************************Output Data Set of Chi-Square Statistics*************************";
    title2 'Chi-Square Tests for 3 by 5 Table of Eye and Hair Color';
run;

   
proc print data=ChiSqData noobs;
    title1 'Chi-Square Statistics for Eye and Hair Color';
    title2 'Output Data Set from the FREQ Procedure';
run;
Eye and Hair Color of European Children

Eye Color
Eyes Frequency Percent Cumulative
Frequency
Cumulative
Percent
blue 222 29.13 222 29.13
brown 341 44.75 563 73.88
green 199 26.12 762 100.00

Hair Color
Hair Frequency Percent Cumulative
Frequency
Cumulative
Percent
black 22 2.89 22 2.89
dark 182 23.88 204 26.77
fair 228 29.92 432 56.69
medium 217 28.48 649 85.17
red 113 14.83 762 100.00

Frequency
Percent
Row Pct
Col Pct
Table of Eyes by Hair
Eyes(Eye Color) Hair(Hair Color)
black dark fair medium red Total
blue
6
0.79
2.70
27.27
51
6.69
22.97
28.02
69
9.06
31.08
30.26
68
8.92
30.63
31.34
28
3.67
12.61
24.78
222
29.13
brown
16
2.10
4.69
72.73
94
12.34
27.57
51.65
90
11.81
26.39
39.47
94
12.34
27.57
43.32
47
6.17
13.78
41.59
341
44.75
green
0
0.00
0.00
0.00
37
4.86
18.59
20.33
69
9.06
34.67
30.26
55
7.22
27.64
25.35
38
4.99
19.10
33.63
199
26.12
Total
22
2.89
182
23.88
228
29.92
217
28.48
113
14.83
762
100.00



Eye and Hair Color of European Children
Output Data Set from PROC FREQ

Eyes Hair COUNT EXPECTED PERCENT
blue black 6 6.409 0.7874
blue dark 51 53.024 6.6929
blue fair 69 66.425 9.0551
blue medium 68 63.220 8.9239
blue red 28 32.921 3.6745
brown black 16 9.845 2.0997
brown dark 94 81.446 12.3360
brown fair 90 102.031 11.8110
brown medium 94 97.109 12.3360
brown red 47 50.568 6.1680
green black 0 5.745 0.0000
green dark 37 47.530 4.8556
green fair 69 59.543 9.0551
green medium 55 56.671 7.2178
green red 38 29.510 4.9869



***********************Frequency Dot Plots*************************
Eye and Hair Color of European Children

Hair Color
Hair Frequency Percent Cumulative
Frequency
Cumulative
Percent
fair 228 29.92 228 29.92
medium 217 28.48 445 58.40
dark 182 23.88 627 82.28
red 113 14.83 740 97.11
black 22 2.89 762 100.00

Dot Plot of Frequencies for Hair


Frequency
Percent
Row Pct
Col Pct
Table of Eyes by Hair
Eyes(Eye Color) Hair(Hair Color)
fair medium dark red black Total
brown
90
11.81
26.39
39.47
94
12.34
27.57
43.32
94
12.34
27.57
51.65
47
6.17
13.78
41.59
16
2.10
4.69
72.73
341
44.75
blue
69
9.06
31.08
30.26
68
8.92
30.63
31.34
51
6.69
22.97
28.02
28
3.67
12.61
24.78
6
0.79
2.70
27.27
222
29.13
green
69
9.06
34.67
30.26
55
7.22
27.64
25.35
37
4.86
18.59
20.33
38
4.99
19.10
33.63
0
0.00
0.00
0.00
199
26.12
Total
228
29.92
217
28.48
182
23.88
113
14.83
22
2.89
762
100.00



***********************Frequency Dot Plots*************************
Eye and Hair Color of European Children

Dot Plot of Frequencies for Eyes by Hair


Dot Plot of Frequencies for Eyes by Hair


Frequency
Percent
Row Pct
Col Pct
Table of Region by Hair
Region(Geographic
Region)
Hair(Hair Color)
fair medium dark red black Total
2
152
19.95
29.46
66.67
134
17.59
25.97
61.75
117
15.35
22.67
64.29
94
12.34
18.22
83.19
19
2.49
3.68
86.36
516
67.72
1
76
9.97
30.89
33.33
83
10.89
33.74
38.25
65
8.53
26.42
35.71
19
2.49
7.72
16.81
3
0.39
1.22
13.64
246
32.28
Total
228
29.92
217
28.48
182
23.88
113
14.83
22
2.89
762
100.00



***********************Frequency Dot Plots*************************
Eye and Hair Color of European Children

Dot Plot of Percents for Region by Hair


Dot Plot of Percents for Region by Hair




***********************Chi-Square Goodness-of-Fit Tests************************
Hair Color of European Children

Hair Color
Hair Frequency Percent Test
Percent
fair 76 30.89 30.00
red 19 7.72 12.00
medium 83 33.74 30.00
dark 65 26.42 25.00
black 3 1.22 3.00

Chi-Square Test
for Specified Proportions
Chi-Square 7.7602
DF 4
Pr > ChiSq 0.1008

Dot Plot of Relative Deviations for Hair



Sample Size = 246



***********************Chi-Square Goodness-of-Fit Tests************************
Hair Color of European Children

Hair Color
Hair Frequency Percent Test
Percent
fair 152 29.46 30.00
red 94 18.22 12.00
medium 134 25.97 30.00
dark 117 22.67 25.00
black 19 3.68 3.00

Chi-Square Test
for Specified Proportions
Chi-Square 21.3824
DF 4
Pr > ChiSq 0.0003

Dot Plot of Relative Deviations for Hair



Sample Size = 516



************************Binomial Proportions************************
Hair and Eye Color of European Children

Eye Color
Eyes Frequency Percent Cumulative
Frequency
Cumulative
Percent
brown 341 44.75 341 44.75
blue 222 29.13 563 73.88
green 199 26.12 762 100.00

Binomial Proportion
Eyes = brown
Proportion 0.4475
ASE 0.0180

Confidence Limits for the Binomial Proportion
Proportion = 0.4475
Type 90% Confidence Limits
Agresti-Coull 0.4181 0.4773
Clopper-Pearson (Exact) 0.4174 0.4779
Wilson 0.4181 0.4773

Test of H0: Proportion = 0.5
ASE under H0 0.0181
Z -2.8981
One-sided Pr < Z 0.0019
Two-sided Pr > |Z| 0.0038


Sample Size = 762

Hair Color
Hair Frequency Percent Cumulative
Frequency
Cumulative
Percent
fair 228 29.92 228 29.92
medium 217 28.48 445 58.40
dark 182 23.88 627 82.28
red 113 14.83 740 97.11
black 22 2.89 762 100.00

Binomial Proportion
Hair = fair
Proportion 0.2992
ASE 0.0166
95% Lower Conf Limit 0.2667
95% Upper Conf Limit 0.3317
Exact Conf Limits
95% Lower Conf Limit 0.2669
95% Upper Conf Limit 0.3331

Test of H0: Proportion = 0.28
ASE under H0 0.0163
Z 1.1812
One-sided Pr > Z 0.1188
Two-sided Pr > |Z| 0.2375

Equivalence Analysis
H0: P - p0 <= Lower Margin or >= Upper Margin
Ha: Lower Margin < P - p0 < Upper Margin
p0 = 0.28 Lower Margin = -0.1 Upper Margin = 0.1
Proportion ASE (Sample)
0.2992 0.0166

Two One-Sided Tests (TOST)
Test Z P-Value
Lower Margin 7.1865 Pr > Z <.0001
Upper Margin -4.8701 Pr < Z <.0001
Overall <.0001

Equivalence Limits 90% Confidence Limits
0.1800 0.3800 0.2719 0.3265


Sample Size = 762



************************Analysis of a 2x2 Contingency Table*************************
Case-Control Study of High Fat/Cholesterol Diet

Frequency
Percent
Row Pct
Col Pct
Table of Exposure by Response
Exposure Response(Heart Disease)
Yes No Total
High Cholesterol Diet
11
47.83
73.33
84.62
4
17.39
26.67
40.00
15
65.22
Low Cholesterol Diet
2
8.70
25.00
15.38
6
26.09
75.00
60.00
8
34.78
Total
13
56.52
10
43.48
23
100.00


Statistics for Table of Exposure by Response

Statistic DF Value Prob
Chi-Square 1 4.9597 0.0259
Likelihood Ratio Chi-Square 1 5.0975 0.0240
Continuity Adj. Chi-Square 1 3.1879 0.0742
Mantel-Haenszel Chi-Square 1 4.7441 0.0294
Phi Coefficient 0.4644
Contingency Coefficient 0.4212
Cramer's V 0.4644
WARNING: 50% of the cells have expected counts less than 5.
(Asymptotic) Chi-Square may not be a valid test.

Pearson Chi-Square Test
Chi-Square 4.9597
DF 1
Asymptotic Pr > ChiSq 0.0259
Exact Pr >= ChiSq 0.0393

Fisher's Exact Test
Cell (1,1) Frequency (F) 11
Left-sided Pr <= F 0.9967
Right-sided Pr >= F 0.0367
Table Probability (P) 0.0334
Two-sided Pr <= P 0.0393

Odds Ratio and Relative Risks
Statistic Value 95% Confidence Limits
Odds Ratio 8.2500 1.1535 59.0029
Relative Risk (Column 1) 2.9333 0.8502 10.1204
Relative Risk (Column 2) 0.3556 0.1403 0.9009

Odds Ratio
Odds Ratio 8.2500
Asymptotic Conf Limits
95% Lower Conf Limit 1.1535
95% Upper Conf Limit 59.0029
Exact Conf Limits
95% Lower Conf Limit 0.8677
95% Upper Conf Limit 105.5488


Sample Size = 23



*************************Output Data Set of Chi-Square Statistics*************************
Chi-Square Tests for 3 by 5 Table of Eye and Hair Color

Frequency
Expected
Cell Chi-Square
Percent
Table of Eyes by Hair
Eyes(Eye Color) Hair(Hair Color)
fair red medium dark black Total
blue
69
66.425
0.0998
9.06
28
32.921
0.7357
3.67
68
63.22
0.3613
8.92
51
53.024
0.0772
6.69
6
6.4094
0.0262
0.79
222
29.13
green
69
59.543
1.5019
9.06
38
29.51
2.4422
4.99
55
56.671
0.0492
7.22
37
47.53
2.3329
4.86
0
5.7454
5.7454
0.00
199
26.12
brown
90
102.03
1.4187
11.81
47
50.568
0.2518
6.17
94
97.109
0.0995
12.34
94
81.446
1.935
12.34
16
9.8451
3.8478
2.10
341
44.75
Total
228
29.92
113
14.83
217
28.48
182
23.88
22
2.89
762
100.00


Statistics for Table of Eyes by Hair

Statistic DF Value Prob
Chi-Square 8 20.9248 0.0073
Likelihood Ratio Chi-Square 8 25.9733 0.0011
Mantel-Haenszel Chi-Square 1 3.7838 0.0518
Phi Coefficient 0.1657
Contingency Coefficient 0.1635
Cramer's V 0.1172


Sample Size = 762



Chi-Square Statistics for Eye and Hair Color
Output Data Set from the FREQ Procedure

N NMISS PCHI DF_PCHI P_PCHI LRCHI DF_LRCHI P_LRCHI
762 0 20.9248 8 .007349898 25.9733 8 .001061424

Cochran-Mantel-Haenszel Statistics

data Migraine;
      input Gender $ Treatment $ Response $ Count @@;
      datalines;
female Active  Better 16   female Active  Same 11
female Placebo Better  5   female Placebo Same 20
male   Active  Better 12   male   Active  Same 16
male   Placebo Better  7   male   Placebo Same 19
;
run;

proc freq data=Migraine;
    tables Gender*Treatment*Response / cmh; 
    weight Count;
    title 'Clinical Trial for Treatment of Migraine Headaches';
    ods graphics off;
run;                 
                  
Clinical Trial for Treatment of Migraine Headaches

Frequency
Percent
Row Pct
Col Pct
Table 1 of Treatment by Response
Controlling for Gender=female
Treatment Response
Better Same Total
Active
16
30.77
59.26
76.19
11
21.15
40.74
35.48
27
51.92
Placebo
5
9.62
20.00
23.81
20
38.46
80.00
64.52
25
48.08
Total
21
40.38
31
59.62
52
100.00

Frequency
Percent
Row Pct
Col Pct
Table 2 of Treatment by Response
Controlling for Gender=male
Treatment Response
Better Same Total
Active
12
22.22
42.86
63.16
16
29.63
57.14
45.71
28
51.85
Placebo
7
12.96
26.92
36.84
19
35.19
73.08
54.29
26
48.15
Total
19
35.19
35
64.81
54
100.00



Clinical Trial for Treatment of Migraine Headaches


Summary Statistics for Treatment by Response
Controlling for Gender

Cochran-Mantel-Haenszel Statistics (Based on Table Scores)
Statistic Alternative Hypothesis DF Value Prob
1 Nonzero Correlation 1 8.3052 0.0040
2 Row Mean Scores Differ 1 8.3052 0.0040
3 General Association 1 8.3052 0.0040

Common Odds Ratio and Relative Risks
Statistic Method Value 95% Confidence Limits
Odds Ratio Mantel-Haenszel 3.3132 1.4456 7.5934
Logit 3.2941 1.4182 7.6515
Relative Risk (Column 1) Mantel-Haenszel 2.1636 1.2336 3.7948
Logit 2.1059 1.1951 3.7108
Relative Risk (Column 2) Mantel-Haenszel 0.6420 0.4705 0.8761
Logit 0.6613 0.4852 0.9013

Breslow-Day Test for
Homogeneity of the Odds Ratios
Chi-Square 1.4929
DF 1
Pr > ChiSq 0.2218


Total Sample Size = 106

Cochran-Armitage Trend Test

data pain;
      input Dose Adverse $ Count @@;
      datalines;
0 No 26   0 Yes  6
1 No 26   1 Yes  7
2 No 23   2 Yes  9
3 No 18   3 Yes 14
4 No  9   4 Yes 23
;
run;

ods graphics on;
proc freq data=Pain;
    tables Adverse*Dose / trend measures cl
           plots=freqplot(twoway=stacked);
    test smdrc;
    exact trend / maxtime=60;
    weight Count;
    title 'Clinical Trial for Treatment of Pain';
run;
ods graphics off;
Clinical Trial for Treatment of Pain

Frequency
Percent
Row Pct
Col Pct
Table of Adverse by Dose
Adverse Dose
0 1 2 3 4 Total
No
26
16.15
25.49
81.25
26
16.15
25.49
78.79
23
14.29
22.55
71.88
18
11.18
17.65
56.25
9
5.59
8.82
28.13
102
63.35
Yes
6
3.73
10.17
18.75
7
4.35
11.86
21.21
9
5.59
15.25
28.13
14
8.70
23.73
43.75
23
14.29
38.98
71.88
59
36.65
Total
32
19.88
33
20.50
32
19.88
32
19.88
32
19.88
161
100.00

Bar Chart of Frequencies for Adverse by Dose



Statistics for Table of Adverse by Dose

Statistic Value ASE 95%
Confidence Limits
Gamma 0.5313 0.0935 0.3480 0.7146
Kendall's Tau-b 0.3373 0.0642 0.2114 0.4631
Stuart's Tau-c 0.4111 0.0798 0.2547 0.5675
Somers' D C|R 0.4427 0.0837 0.2786 0.6068
Somers' D R|C 0.2569 0.0499 0.1592 0.3547
Pearson Correlation 0.3776 0.0714 0.2378 0.5175
Spearman Correlation 0.3771 0.0718 0.2363 0.5178
Lambda Asymmetric C|R 0.1250 0.0662 0.0000 0.2547
Lambda Asymmetric R|C 0.2373 0.0837 0.0732 0.4014
Lambda Symmetric 0.1604 0.0621 0.0388 0.2821
Uncertainty Coefficient C|R 0.0515 0.0191 0.0140 0.0890
Uncertainty Coefficient R|C 0.1261 0.0467 0.0346 0.2175
Uncertainty Coefficient Symmetric 0.0731 0.0271 0.0199 0.1262

Somers' D R|C
Somers' D R|C 0.2569
ASE 0.0499
95% Lower Conf Limit 0.1592
95% Upper Conf Limit 0.3547

Test of H0: Somers' D R|C = 0
ASE under H0 0.0499
Z 5.1511
One-sided Pr > Z <.0001
Two-sided Pr > |Z| <.0001

Cochran-Armitage Trend Test
Statistic (Z) -4.7918
Asymptotic Test
One-sided Pr < Z <.0001
Two-sided Pr > |Z| <.0001
Exact Test
One-sided Pr <= Z <.0001
Two-sided Pr >= |Z| <.0001


Sample Size = 161

Friedman Chi-Square Test

data Hypnosis;
      length Emotion $ 10;
      input Subject Emotion $ SkinResponse @@;
      datalines;
1 fear 23.1  1 joy 22.7  1 sadness 22.5  1 calmness 22.6
2 fear 57.6  2 joy 53.2  2 sadness 53.7  2 calmness 53.1
3 fear 10.5  3 joy  9.7  3 sadness 10.8  3 calmness  8.3
4 fear 23.6  4 joy 19.6  4 sadness 21.1  4 calmness 21.6
5 fear 11.9  5 joy 13.8  5 sadness 13.7  5 calmness 13.3
6 fear 54.6  6 joy 47.1  6 sadness 39.2  6 calmness 37.0
7 fear 21.0  7 joy 13.6  7 sadness 13.7  7 calmness 14.8
8 fear 20.3  8 joy 23.6  8 sadness 16.3  8 calmness 14.8
;
run;

proc freq data=Hypnosis;
tables Subject*Emotion*SkinResponse / 
           cmh2 scores=rank noprint;
run;

proc freq data=Hypnosis;
tables Emotion*SkinResponse /
      cmh2 scores=rank noprint;
run;

Summary Statistics for Emotion by SkinResponse
Controlling for Subject

Cochran-Mantel-Haenszel Statistics (Based on Rank Scores)
Statistic Alternative Hypothesis DF Value Prob
1 Nonzero Correlation 1 0.2400 0.6242
2 Row Mean Scores Differ 3 6.4500 0.0917


Total Sample Size = 32




Summary Statistics for Emotion by SkinResponse

Cochran-Mantel-Haenszel Statistics (Based on Rank Scores)
Statistic Alternative Hypothesis DF Value Prob
1 Nonzero Correlation 1 0.0001 0.9933
2 Row Mean Scores Differ 3 0.5678 0.9038


Total Sample Size = 32

Cochran Q Test

proc format;
    value $ResponseFmt 'F'='Favorable'
                       'U'='Unfavorable';
run;

   
data drugs;
      input Drug_A $ Drug_B $ Drug_C $ Count @@;
      datalines;
F F F  6   U F F  2   
F F U 16   U F U  4    
F U F  2   U U F  6   
F U U  4   U U U  6  
;
run;

proc freq data=Drugs;
    tables Drug_A Drug_B Drug_C / nocum;
    tables Drug_A*Drug_B*Drug_C / agree noprint;
    format Drug_A Drug_B Drug_C $ResponseFmt.;
    weight Count;
    title 'Study of Three Drug Treatments for a Chronic Disease';
run;
Study of Three Drug Treatments for a Chronic Disease

Drug_A Frequency Percent
Favorable 28 60.87
Unfavorable 18 39.13

Drug_B Frequency Percent
Favorable 28 60.87
Unfavorable 18 39.13

Drug_C Frequency Percent
Favorable 16 34.78
Unfavorable 30 65.22



Study of Three Drug Treatments for a Chronic Disease


Statistics for Table 1 of Drug_B by Drug_C
Controlling for Drug_A=Favorable

McNemar's Test
Statistic (S) 10.8889
DF 1
Pr > S 0.0010

Simple Kappa Coefficient
Kappa -0.0328
ASE 0.1167
95% Lower Conf Limit -0.2615
95% Upper Conf Limit 0.1960


Sample Size = 28

Agreement Plot of Drug_B and Drug_C



Statistics for Table 2 of Drug_B by Drug_C
Controlling for Drug_A=Unfavorable

McNemar's Test
Statistic (S) 0.4000
DF 1
Pr > S 0.5271

Simple Kappa Coefficient
Kappa -0.1538
ASE 0.2230
95% Lower Conf Limit -0.5909
95% Upper Conf Limit 0.2832


Sample Size = 18

Agreement Plot of Drug_B and Drug_C




Study of Three Drug Treatments for a Chronic Disease


Summary Statistics for Drug_B by Drug_C
Controlling for Drug_A

Overall Kappa Coefficient
Kappa -0.0588
ASE 0.1034
95% Lower Conf Limit -0.2615
95% Upper Conf Limit 0.1439

Test for Equal Kappa Coefficients
Chi-Square 0.2314
DF 1
Pr > ChiSq 0.6305

Cochran's Q, for Drug_A by
Drug_B by Drug_C
Statistic (Q) 8.4706
DF 2
Pr > Q 0.0145


Total Sample Size = 46

Plot of Kappa Coefficients with 95% Confidence Limits