SAS Frequency Tabulations and Contingency Tables (Crosstabs)
SAS Twoway Cross-Tabulations for Matched Frequency Data
/***********************************************************
This example illustrates:
How to set up a permanent SAS data set with user-defined formats
How to read raw data from a file with two lines per case
How to save user-defined formats permanently
How to recode continuous variables into categories
Procs used:
Proc Format
Proc Datasets
Proc Contents
Proc Means
Filename: afifi_setup.sas
************************************************************/
OPTIONS FORMCHAR="|----|+|---+=|-/\*";
TITLE "AFIFI DATA";
LIBNAME SASDATA2 V9 "c:\temp\sasdata2\";
LIBNAME LIBRARY "c:\temp\sasdata2\";
OPTIONS FMTSEARCH=(WORK LIBRARY);
DATA SASDATA2.AFIFI;
INFILE "afifi.dat";
INPUT
#1 IDNUM 1-4 AGE 5-8 SEX 13-15 SURVIVE 16 SHOKTYPE 17-20 SBP1 21-24
MAP1 25-28 HEART1 29-32 CARDIAC1 45-48 2 URINE1 57-60 HGB1 69-72 1
#2 SBP2 21-24 MAP2 25-28 HEART2 29-32 CARDIAC2 45-48 2 URINE2 57-60
HGB2 69-72 1;
LABEL SHOCK="Shock type"
SBP1="Systolic BP at time 1"
SBP2="Systolic BP at time 2"
MAP1="Mean arterial pressure at time 1"
MAP2="Mean arterial pressure at time 2"
HEART1="Heart rate at time 1"
HEART2="Heart rate at time 2"
CARDIAC1="Cardiac index at time 1"
CARDIAC2="Cardiac index at time 2"
URINE1="Urinary output at time 1"
URINE2="Urinary output at time 2"
HGB1="Hemoglobin at time 1"
HGB2="Hemoglobin at time 2" ;
IF SHOKTYPE=2 THEN SHOCK=1;
IF SHOKTYPE IN (3,4,5,6,7) THEN SHOCK=2;
IF SURVIVE=1 THEN DIED=0;
IF SURVIVE=3 THEN DIED=1;
SBPDIFF=SBP2-SBP1;
LABEL SHOCK="Binary Shock";
if Urine1 = 0 then NoUrine1 = 1;
if Urine1 > 0 then NoUrine1 = 2;
if Urine2 = 0 then NoUrine2 = 1;
if Urine2 > 0 then NoUrine2 = 2;
RUN;
PROC FORMAT LIB=LIBRARY ;
VALUE SEXFMT 1="1: Male" 2="2: Female" ;
VALUE SURVFMT 1="1: Lived" 3="3: Died" ;
VALUE SHKTYFMT 2="2: Non-Shock"
3="3: Hypovolemic"
4="4: Cardiogenic"
5="5: Bacterial"
6="6: Neurogenic"
7="7: Other";
VALUE SHOCKFMT 1="1: No shock" 2="2: Shock" ;
value urinefmt 1="No Urine"
2="Urine";
RUN;
PROC DATASETS LIB=SASDATA2;
MODIFY AFIFI;
FORMAT SEX SEXFMT. SURVIVE SURVFMT.
SHOKTYPE SHKTYFMT. SHOCK SHOCKFMT.
nourine1 nourine2 urinefmt.;
RUN;
PROC CONTENTS DATA=SASDATA2.AFIFI;
RUN;
proc means data=sasdata2.afifi;
run;
The log from that results from running Proc Format is shown below. These formats will be stored in the libref, LIBRARY, and thus will be permanent. SAS expects to find formats in LIBRARY, and it is OK that we assigned the libref LIBRARY to the same location as SASDATA2.
639 PROC FORMAT LIB=LIBRARY ;
640 VALUE SEXFMT 1="1: Male" 2="2: Female" ;
NOTE: Format SEXFMT has been written to LIBRARY.FORMATS.
641 VALUE SURVFMT 1="1: Lived" 3="3: Died" ;
NOTE: Format SURVFMT has been written to LIBRARY.FORMATS.
642 VALUE SHKTYFMT 2="2: Non-Shock"
643 3="3: Hypovolemic"
644 4="4: Cardiogenic"
645 5="5: Bacterial"
646 6="6: Neurogenic"
647 7="7: Other";
NOTE: Format SHKTYFMT has been written to LIBRARY.FORMATS.
648 VALUE SHOCKFMT 1="1: No shock" 2="2: Shock" ;
NOTE: Format SHOCKFMT has been written to LIBRARY.FORMATS.
649 value urinefmt 1="No Urine"
650 2="Urine";
NOTE: Format URINEFMT has been written to LIBRARY.FORMATS.
651 RUN;
The log from Proc Datasets is shown below. Note that these formats are now assigned permanently to SASDATA2.AFIFI. However, they are still located in a separate location (the formats catalog). The formats are logically attached to the variables, although not physically attached. Notice that we assigned the same format URINEFMT. to both NOURINE1 and NOURINE2. We want to be sure that the modify statement for our data set was successful, as noted in the log.
652 PROC DATASETS LIB=SASDATA2;
Directory
Libref SASDATA2
Engine V9
Physical Name c:\temp\sasdata2
File Name c:\temp\sasdata2
Member File
# Name Type Size Last Modified
1 AFIFI DATA 33792 29Jan08:07:59:30
2 BASEBALL DATA 82944 20Jun02:06:12:00
3 BUSINESS DATA 17408 20Aug06:03:05:00
4 BUSINESS2 DATA 17408 10Jan08:09:35:10
5 CARS DATA 33792 22Aug06:00:03:00
6 FITNESS DATA 9216 01Nov07:19:06:54
7 FORMATS CATALOG 21504 29Jan08:07:59:30
8 GPA DATA 17408 01Nov07:19:06:54
9 HEARTRATE DATA 17408 01Nov07:19:20:56
10 IRIS DATA 13312 20Jun02:06:12:00
11 MARCH DATA 62464 01Nov07:19:06:55
12 SHIP DATA 5120 20Jun02:06:07:00
13 TECUMSEH DATA 1147904 01Jun05:23:00:00
653 MODIFY AFIFI;
654 FORMAT SEX SEXFMT. SURVIVE SURVFMT.
655 SHOKTYPE SHKTYFMT. SHOCK SHOCKFMT.
656 nourine1 nourine2 urinefmt.;
657 RUN;
NOTE: MODIFY was successful for SASDATA2.AFIFI.DATA.
The output from Proc Contents is shown below. Notice that the user-defined formats are listed in the Contents, next to the variables to which they apply.
AFIFI DATA
The CONTENTS Procedure
Data Set Name SASDATA2.AFIFI Observations 113
Member Type DATA Variables 22
Engine V9 Indexes 0
Created Tuesday, January 29, 2008 07:59:30 AM Observation Length 176
Last Modified Tuesday, January 29, 2008 07:59:52 AM Deleted Observations 0
Protection Compressed NO
Data Set Type Sorted NO
Label
Data Representation WINDOWS_32
Encoding wlatin1 Western (Windows)
Alphabetic List of Variables and Attributes
# Variable Type Len Format Label
2 AGE Num 8
9 CARDIAC1 Num 8 Cardiac index at time 1
15 CARDIAC2 Num 8 Cardiac index at time 2
19 DIED Num 8
8 HEART1 Num 8 Heart rate at time 1
14 HEART2 Num 8 Heart rate at time 2
11 HGB1 Num 8 Hemoglobin at time 1
17 HGB2 Num 8 Hemoglobin at time 2
1 IDNUM Num 8
7 MAP1 Num 8 Mean arterial pressure at time 1
13 MAP2 Num 8 Mean arterial pressure at time 2
21 NoUrine1 Num 8 URINEFMT.
22 NoUrine2 Num 8 URINEFMT.
6 SBP1 Num 8 Systolic BP at time 1
12 SBP2 Num 8 Systolic BP at time 2
20 SBPDIFF Num 8
3 SEX Num 8 SEXFMT.
18 SHOCK Num 8 SHOCKFMT. Binary Shock
5 SHOKTYPE Num 8 SHKTYFMT.
4 SURVIVE Num 8 SURVFMT.
10 URINE1 Num 8 Urinary output at time 1
16 URINE2 Num 8 Urinary output at time 2
The output from Proc Means is shown below:
The MEANS Procedure
Variable Label N Mean Std Dev Minimum
----------------------------------------------------------------------------------------------
IDNUM 113 635.6991150 82.9653418 340.0000000
AGE 113 54.6283186 16.5966836 16.0000000
SEX 113 1.4778761 0.5017353 1.0000000
SURVIVE 113 1.7610619 0.9753602 1.0000000
SHOKTYPE 113 3.9380531 1.6970730 2.0000000
SBP1 Systolic BP at time 1 111 105.8558559 30.7691838 26.0000000
MAP1 Mean arterial pressure at time 1 113 73.4247788 22.0039791 15.0000000
HEART1 Heart rate at time 1 113 104.4424779 29.6093428 25.0000000
CARDIAC1 Cardiac index at time 1 110 2.5704545 1.4828335 0.1700000
URINE1 Urinary output at time 1 113 54.4336283 112.3486185 0
HGB1 Hemoglobin at time 1 113 11.4362832 2.5388785 6.6000000
SBP2 Systolic BP at time 2 113 110.7876106 37.0102426 38.0000000
MAP2 Mean arterial pressure at time 2 113 73.2123894 27.0826946 22.0000000
HEART2 Heart rate at time 2 113 96.3893805 29.6480647 25.0000000
CARDIAC2 Cardiac index at time 2 113 2.9354867 1.3358103 0.6600000
URINE2 Urinary output at time 2 113 77.5221239 135.9852997 0
HGB2 Hemoglobin at time 2 113 10.5345133 2.0166171 5.9000000
SHOCK Binary Shock 113 1.6991150 0.4606857 1.0000000
DIED 113 0.3805310 0.4876801 0
SBPDIFF 111 4.4414414 35.6545763 -67.0000000
NoUrine1 113 1.5663717 0.4977827 1.0000000
NoUrine2 113 1.8761062 0.3309279 1.0000000
----------------------------------------------------------------------------------------------
Variable Label Maximum
----------------------------------------------------------
IDNUM 758.0000000
AGE 90.0000000
SEX 2.0000000
SURVIVE 3.0000000
SHOKTYPE 7.0000000
SBP1 Systolic BP at time 1 171.0000000
MAP1 Mean arterial pressure at time 1 124.0000000
HEART1 Heart rate at time 1 217.0000000
CARDIAC1 Cardiac index at time 1 7.6300000
URINE1 Urinary output at time 1 510.0000000
HGB1 Hemoglobin at time 1 18.0000000
SBP2 Systolic BP at time 2 182.0000000
MAP2 Mean arterial pressure at time 2 117.0000000
HEART2 Heart rate at time 2 221.0000000
CARDIAC2 Cardiac index at time 2 7.9400000
URINE2 Urinary output at time 2 850.0000000
HGB2 Hemoglobin at time 2 15.5000000
SHOCK Binary Shock 2.0000000
DIED 1.0000000
SBPDIFF 94.0000000
NoUrine1 2.0000000
NoUrine2 2.0000000
----------------------------------------------------------
/*****************************************************************
This example illustrates:
How to use a permanent SAS data set with formats
How to use the SAS ods system to select output
How to get appropriate statistics for matched frequency data
How to enter data with frequency weights
The following tests are illustrated:
McNemar’s test of symmetry
The following measures of agreement are illustrated:
Cohen's kappa
Weighted kappa
Procs used:
Proc Univariate
Proc Freq
Proc Print
Filename: matchfreq.sas
*******************************************************************/
OPTIONS FORMCHAR="|----|+|---+=|-/\*";
LIBNAME SASDATA2 V9 "c:\documents and settings\kathy\desktop\sasdata2\";
LIBNAME LIBRARY "c:\documents and settings\kathy\desktop\sasdata2\";
OPTIONS FMTSEARCH=(WORK LIBRARY);
OPTIONS NOFMTERR;
The libname commands above allow us to access our permanent SAS data set(s) and formats in later runs. These commands can be run after shutting down SAS and restarting it. The formats stored in the libref LIBRARY will be found and utilized by SAS when it displays the values of the variables contained in SASDATA2.AFIFI. The options nofmterr statement allows SAS to proceed even if there is a problem in locating the correct user-defined formats for the variables.
We now take a look at the distribution of Urine1 and Urine2. Only part of the output is shown, along with the histograms. Notice that many patients have zero urinary output at time 1 and at time 2. Is the proportion of patients with zero urinary output lower at time 2 than at time 1?
title "Distribution of Urinary output";
title2 "At Time 1 and Time 2";
proc univariate data=sasdata2.afifi;
var urine1 urine2;
histogram;
run;
The UNIVARIATE Procedure
Variable: URINE1 (Urinary output at time 1)
Moments
N 113 Sum Weights 113
Mean 54.4336283 Sum Observations 6151
Std Deviation 112.348618 Variance 12622.2121
Skewness 2.44944472 Kurtosis 5.2023573
Uncorrected SS 1748509 Corrected SS 1413687.75
Coeff Variation 206.395609 Std Error Mean 10.568869
Basic Statistical Measures
Location Variability
Mean 54.43363 Std Deviation 112.34862
Median 1.00000 Variance 12622
Mode 0.00000 Range 510.00000
Interquartile Range 41.00000
The UNIVARIATE Procedure
Variable: URINE2 (Urinary output at time 2)
Moments
N 113 Sum Weights 113
Mean 77.5221239 Sum Observations 8760
Std Deviation 135.9853 Variance 18492.0017
Skewness 3.1905204 Kurtosis 12.067525
Uncorrected SS 2750198 Corrected SS 2071104.19
Coeff Variation 175.414827 Std Error Mean 12.7924209
Basic Statistical Measures
Location Variability
Mean 77.52212 Std Deviation 135.98530
Median 25.00000 Variance 18492
Mode 1.00000 Range 850.00000
Interquartile Range 87.00000
Although its hard to tell for sure, it looks like there is a greater proportion of patients with zero urinary output at time one than at time two. This makes sense, because they are supposed to be recovering in the Emergency Department.
[pic] [pic]
Another way to check the data is to look at frequencies of each variable. This produces a lot of output, but it is useful, when we’re trying to examine the values for each variable. From the output, we can see that 49 patients (43.36%) have zero urinary output at time one, while only 14 (12.39%) have zero urinary output at time two. However, we still don’t know if this difference is significant.
proc freq data=sasdata2.afifi;
tables urine1 urine2;
run;
Distribution of Urinary output
At Time 1 and Time 2
The FREQ Procedure
Urinary output at time 1
Cumulative Cumulative
URINE1 Frequency Percent Frequency Percent
-----------------------------------------------------------
0 49 43.36 49 43.36
1 12 10.62 61 53.98
2 1 0.88 62 54.87
3 2 1.77 64 56.64
4 1 0.88 65 57.52
5 3 2.65 68 60.18
7 1 0.88 69 61.06
10 3 2.65 72 63.72
12 2 1.77 74 65.49
15 2 1.77 76 67.26
21 1 0.88 77 68.14
22 1 0.88 78 69.03
23 1 0.88 79 69.91
28 1 0.88 80 70.80
30 2 1.77 82 72.57
33 1 0.88 83 73.45
40 1 0.88 84 74.34
41 1 0.88 85 75.22
42 1 0.88 86 76.11
50 1 0.88 87 76.99
53 1 0.88 88 77.88
57 1 0.88 89 78.76
60 1 0.88 90 79.65
61 1 0.88 91 80.53
80 2 1.77 93 82.30
100 1 0.88 94 83.19
110 3 2.65 97 85.84
140 1 0.88 98 86.73
160 2 1.77 100 88.50
190 1 0.88 101 89.38
200 1 0.88 102 90.27
205 1 0.88 103 91.15
277 1 0.88 104 92.04
318 1 0.88 105 92.92
320 1 0.88 106 93.81
370 1 0.88 107 94.69
375 1 0.88 108 95.58
377 1 0.88 109 96.46
383 1 0.88 110 97.35
405 1 0.88 111 98.23
450 1 0.88 112 99.12
510 1 0.88 113 100.00
Urinary output at time 2
Cumulative Cumulative
URINE2 Frequency Percent Frequency Percent
-----------------------------------------------------------
0 14 12.39 14 12.39
1 15 13.27 29 25.66
2 2 1.77 31 27.43
3 2 1.77 33 29.20
4 2 1.77 35 30.97
5 2 1.77 37 32.74
10 2 1.77 39 34.51
11 1 0.88 40 35.40
12 2 1.77 42 37.17
15 2 1.77 44 38.94
16 1 0.88 45 39.82
17 2 1.77 47 41.59
20 5 4.42 52 46.02
21 1 0.88 53 46.90
22 1 0.88 54 47.79
23 2 1.77 56 49.56
25 1 0.88 57 50.44
30 2 1.77 59 52.21
37 3 2.65 62 54.87
38 1 0.88 63 55.75
40 1 0.88 64 56.64
42 4 3.54 68 60.18
43 2 1.77 70 61.95
44 2 1.77 72 63.72
48 1 0.88 73 64.60
50 2 1.77 75 66.37
52 1 0.88 76 67.26
55 1 0.88 77 68.14
58 1 0.88 78 69.03
65 1 0.88 79 69.91
73 1 0.88 80 70.80
75 3 2.65 83 73.45
77 1 0.88 84 74.34
88 2 1.77 86 76.11
90 1 0.88 87 76.99
95 1 0.88 88 77.88
97 1 0.88 89 78.76
100 1 0.88 90 79.65
109 1 0.88 91 80.53
110 1 0.88 92 81.42
115 1 0.88 93 82.30
125 1 0.88 94 83.19
126 1 0.88 95 84.07
150 1 0.88 96 84.96
152 1 0.88 97 85.84
161 1 0.88 98 86.73
176 1 0.88 99 87.61
180 1 0.88 100 88.50
200 2 1.77 102 90.27
226 1 0.88 103 91.15
235 1 0.88 104 92.04
270 1 0.88 105 92.92
300 1 0.88 106 93.81
350 1 0.88 107 94.69
381 1 0.88 108 95.58
400 1 0.88 109 96.46
500 1 0.88 110 97.35
525 1 0.88 111 98.23
625 1 0.88 112 99.12
850 1 0.88 113 100.00
Let’s take a look at a printout of a few cases from the data file, using Proc Print. Formatted values are automatically used for NOURINE1 and NOURINE2.
title "Printout Using Formatted Values";
proc print data=sasdata2.afifi(obs=25);
var idnum urine1 urine2 nourine1 nourine2;
run;
Printout Using Formatted Values
Obs IDNUM URINE1 URINE2 NoUrine1 NoUrine2
1 340 0 15 No Urine Some Urine
2 412 110 50 Some Urine Some Urine
3 426 80 75 Some Urine Some Urine
4 444 5 10 Some Urine Some Urine
5 515 140 73 Some Urine Some Urine
6 517 110 180 Some Urine Some Urine
7 518 80 90 Some Urine Some Urine
8 522 10 55 Some Urine Some Urine
9 526 21 88 Some Urine Some Urine
10 527 1 1 Some Urine Some Urine
11 528 5 500 Some Urine Some Urine
12 529 10 15 Some Urine Some Urine
13 530 50 75 Some Urine Some Urine
14 535 22 43 Some Urine Some Urine
15 537 40 50 Some Urine Some Urine
16 539 33 20 Some Urine Some Urine
17 540 0 115 No Urine Some Urine
18 541 0 23 No Urine Some Urine
19 543 0 1 No Urine Some Urine
20 545 0 5 No Urine Some Urine
21 546 0 40 No Urine Some Urine
22 549 0 100 No Urine Some Urine
23 554 100 525 Some Urine Some Urine
24 555 0 37 No Urine Some Urine
25 560 0 1 No Urine Some Urine
To use only the numeric values, specify use a format statement to tell SAS to assign *no* formats to the variables (format _all_;).
title "Printout Using Unformatted Values";
proc print data=sasdata2.afifi(obs=25);
var idnum urine1 urine2 nourine1 nourine2;
format _all_;
run;
We’re now ready to test whether the proportion of patients with no urinary output at time 1 is equal to the proportion of patients with no urinary output at time 2 (H0: (1 = (2), using McNemar’s test. We first run the procedure using ods trace on. This displays the names of the output generated in the SAS log.
ods trace on;
title "Matched Data";
title2 "McNemar's Test";
proc freq data=sasdata2.afifi;
tables NoUrine1 * NoUrine2 / norow nocol agree;
exact mcnemar;
run;
ods trace off;
The SAS log from these commands is shown below. The Cohen’s kappa is displayed in the output, and is labeled SimpleKappa. We can give an ods statement to exclude that portion of the output. The ods system allows a lot of flexibility in choosing SAS output to display for any procedure.
34 ods trace on;
35 title "Matched Data";
36 title2 "McNemar's Test";
37 proc freq data=sasdata2.afifi;
38 tables NoUrine1 * NoUrine2 / norow nocol agree;
39 exact mcnemar;
40 run;
Output Added:
-------------
Name: CrossTabFreqs
Label: Cross-Tabular Freq Table
Data Name:
Path: Freq.Table1.CrossTabFreqs
-------------
Output Added:
-------------
Name: McNemarsTest
Label: McNemar's Test
Template: Base.Freq.StatFactoid
Path: Freq.Table1.McNemarsTest
-------------
Output Added:
-------------
Name: SimpleKappa
Label: Simple Kappa Coefficient
Template: Base.Freq.StatFactoid
Path: Freq.Table1.SimpleKappa
-------------
NOTE: There were 113 observations read from the data set SASDATA2.AFIFI.
41 ods trace off;
title "Matched Data";
title2 "McNemar's Test";
ods exclude SimpleKappa;
proc freq data=sasdata2.afifi;
tables NoUrine1 * NoUrine2 / norow nocol agree;
exact mcnemar;
run;
The agree option gives us both McNemar’s test and Cohen’s kappa, but we have excluded kappa from the output. We also requested an Exact test for McNemars test by using exact mcnemar. We reject H0 and conclude that there is a higher proportion of patients with no urinary output at time one than at time two ((2 1df = 31.41, p < .0001).
Matched Data
McNemar's Test
The FREQ Procedure
Table of NoUrine1 by NoUrine2
NoUrine1 NoUrine2
Frequency |
Percent |No Urine|Some Uri| Total
| |ne |
-----------+--------+--------+
No Urine | 12 | 37 | 49
| 10.62 | 32.74 | 43.36
-----------+--------+--------+
Some Urine | 2 | 62 | 64
| 1.77 | 54.87 | 56.64
-----------+--------+--------+
Total 14 99 113
12.39 87.61 100.00
Statistics for Table of NoUrine1 by NoUrine2
McNemar's Test
------------------------------
Statistic (S) 31.4103
DF 1
Asymptotic Pr > S = S 2.841E-09
Sample Size = 113
We now look at two examples using Cohen’s Kappa, which is a chance-corrected measure of agreement for matched data. This time we create a temporary SAS data set by entering the data in the SAS enhanced program editor. We then create a format and assign it to the variables EXAMINERA and EXAMINERB, using Proc Datasets. These formats also be temporary and will be stored in the WORK library.
*----------------COHEN'S KAPPA FOR INTER-RATER RELIABILITY;
DATA GRADERS;
INPUT CANDIDATE EXAMINERA EXAMINERB;
CARDS;
1 1 2
2 0 0
3 0 0
4 2 2
5 0 0
6 4 3
7 0 0
8 0 0
9 0 0
10 2 3
11 1 2
12 2 3
13 0 1
14 4 3
15 4 3
16 1 2
17 0 2
18 1 2
19 2 3
20 0 0
21 2 3
22 4 4
23 0 0
24 0 0
25 4 3
26 0 2
27 1 2
28 3 4
29 2 3
;
proc format;
value ratingfmt 0="Terrible"
1="So-So"
2="Moderate"
3="Good"
4="Excellent";
run;
proc datasets lib=work;
modify graders;
format examinera examinerb ratingfmt.;
run;
In this case we exclude the SymmetryTest portion of the output (a modification of McNemar’s test, called Bowker’s test for a square table that is greater than 2 by 2).
ods trace on;
title1 "Matched Data";
title2 "Agreement for Two Graders";
ods exclude SymmetryTest;
PROC FREQ DATA=GRADERS order=internal;
TABLES EXAMINERA * EXAMINERB / AGREE nocol norow ;
RUN;
ods trace off;
Matched Data 08:25 Tuesday, January 29, 2008 11
Agreement for Two Graders
The FREQ Procedure
Table of EXAMINERA by EXAMINERB
EXAMINERA EXAMINERB
Frequency |
Percent |Terrible|So-So |Moderate|Good |Excellen| Total
| | | | |t |
----------+--------+--------+--------+--------+--------+
Terrible | 9 | 1 | 2 | 0 | 0 | 12
| 31.03 | 3.45 | 6.90 | 0.00 | 0.00 | 41.38
----------+--------+--------+--------+--------+--------+
So-So | 0 | 0 | 5 | 0 | 0 | 5
| 0.00 | 0.00 | 17.24 | 0.00 | 0.00 | 17.24
----------+--------+--------+--------+--------+--------+
Moderate | 0 | 0 | 1 | 5 | 0 | 6
| 0.00 | 0.00 | 3.45 | 17.24 | 0.00 | 20.69
----------+--------+--------+--------+--------+--------+
Good | 0 | 0 | 0 | 0 | 1 | 1
| 0.00 | 0.00 | 0.00 | 0.00 | 3.45 | 3.45
----------+--------+--------+--------+--------+--------+
Excellent | 0 | 0 | 0 | 4 | 1 | 5
| 0.00 | 0.00 | 0.00 | 13.79 | 3.45 | 17.24
----------+--------+--------+--------+--------+--------+
Total 9 1 8 9 2 29
31.03 3.45 27.59 31.03 6.90 100.00
Statistics for Table of EXAMINERA by EXAMINERB
Kappa Statistics
Statistic Value ASE 95% Confidence Limits
------------------------------------------------------------
Simple Kappa 0.2103 0.0852 0.0433 0.3773
Weighted Kappa 0.5797 0.0717 0.4391 0.7203
Sample Size = 29
This output gives Cohen’s Kappa and Weighted Kappa, plus a 95% Confidence Interval for each of these statistics. However, these confidence intervals cannot be used as a substitute for a statistical test, because they are not calculated under H0:(=0. We then rerun the commands, requesting test statistics for Kappa and Weighted Kappa, using a test statement.
title "Matched Data";
title2 "Test for Kappa and Weighted Kappa";
ds exclude symmetrytest;
PROC FREQ DATA=GRADERS order=internal;
TABLES EXAMINERA * EXAMINERB / AGREE nocol norow ;
test kappa wtkap;
RUN;
The additional output generated by the test statement is shown below. Notice that there is now an additional value for ASE (Asymptotic Standard Error) of Kappa under H0. This is what is used to generate the asymptotic test of H0. You will also see that the ASE under H0 is different from the ASE. SAS also tells you the null hypothesis that it is testing.
Statistics for Table of EXAMINERA by EXAMINERB
Simple Kappa Coefficient
--------------------------------
Kappa 0.2103
ASE 0.0852
95% Lower Conf Limit 0.0433
95% Upper Conf Limit 0.3773
Test of H0: Kappa = 0
ASE under H0 0.0857
Z 2.4544
One-sided Pr > Z 0.0071
Two-sided Pr > |Z| 0.0141
Statistics for Table of EXAMINERA by EXAMINERB
Weighted Kappa Coefficient
--------------------------------
Weighted Kappa 0.5797
ASE 0.0717
95% Lower Conf Limit 0.4391
95% Upper Conf Limit 0.7203
Test of H0: Weighted Kappa = 0
ASE under H0 0.1231
Z 4.7110
One-sided Pr > Z |Z| Z |Z| = K
Estimate 0.0000
99% Lower Conf Limit 0.0000
99% Upper Conf Limit 4.604E-04
Two-sided Pr >= |K|
Estimate 0.0000
99% Lower Conf Limit 0.0000
99% Upper Conf Limit 4.604E-04
Number of Samples 10000
Initial Seed 783358001
The FREQ Procedure
Statistics for Table of derm1 by derm2
Weighted Kappa Coefficient
--------------------------------
Weighted Kappa (K) 0.5082
ASE 0.0655
95% Lower Conf Limit 0.3798
95% Upper Conf Limit 0.6366
Test of H0: Weighted Kappa = 0
ASE under H0 0.0739
Z 6.8766
One-sided Pr > Z |Z| = K
Estimate 0.0000
99% Lower Conf Limit 0.0000
99% Upper Conf Limit 4.604E-04
Two-sided Pr >= |K|
Estimate 0.0000
99% Lower Conf Limit 0.0000
99% Upper Conf Limit 4.604E-04
Number of Samples 10000
Initial Seed 1276579046
Sample Size = 88
................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related download
- sas frequency tabulations and contingency tables crosstabs
- sas procedures for common statistical analyses
- proc reg syntax
- data is in sas dataset leaders csu east bay
- 20 stanford university
- extracting cases with a given string from sas
- working with sas formats catalogs
- sas data quality cleanse techniques for merge purge on
- college of education university of iowa
Related searches
- free tables and graphs worksheets
- average attorney contingency fees
- frequency and relative frequency table
- frequency and relative frequency calculator
- sas convert character date to sas date
- frequency distribution and relative frequency
- exponential and linear tables worksheet
- 2020 federal income tax tables and brackets
- ratios tables and graphs worksheet
- creating tables and graphs ratios
- attorney contingency fee percentages
- contingency fee lawyer