12.6 - Table Statistics12.6 - Table Statistics
There are a few possible statistical table options available in the FREQ procedure. Unfortunately, we don't have the luxury of digressing and discussing in this course when it is appropriate to use each of the statistics. We merely make ourselves aware of their existence in SAS should we need them in analyzing our data in the future. The options include:
- CHISQ, which requests a chi-square test of homogeneity or independence. Reported measures include the phi coefficient, the contingency coefficient, and Cramer's V. For 2×2 tables, Fisher's exact test is also included.
- MEASURES, which requests a basic set of measures of association and their standard errors. Measures include Pearson and Spearman correlation coefficients, gamma, Kendall's tau-b, Stuart's tau-c, Somer's D, lambda, and uncertainty coefficients. For 2×2 tables, odds ratios and risk ratios (with their confidence intervals) are reported.
- CMH, which requests Cochran-Mantel-Haenszel statistsics, which test for association between a row and column variable after adjusting for all of the other variables in the tables statement. For 2×2 tables, Breslow's test for homogeneity of odds ratios is reported as well.
- ALL, which requests all of the tests and measures provided by the CHISQ, MEASURE, and CMH options.
- EXACT, which requests Fisher's Exact Test for tables larger than 2×2 tables. Note that this can take painfully long to compute for large tables.
Of course, you can always refer to the SAS Help and Documentation for the technical details of the statistical tests and measures.
For the remaining examples in this lesson, we need an analysis data set with which to work. The analysis data set (click to save!) that we'll use contains (just!) four variables pulled from the ICDB background data set (with which we've already been working!), the ICDB cystoscopy data set and the ICDB symptoms data set. The following program merely displays the variable names of, and the first 15 observations in, the analysis data set:
OPTIONS NOFMTERR; PROC CONTENTS data = icdb.analysis position; title 'The Analysis data set'; RUN; PROC PRINT data = icdb.analysis (OBS = 15); title 'The Analysis data set'; RUN;
Launch and run the SAS program. From the CONTENTS procedure output, you should see that the analysis data set contains 638 observations and the following four variables:
Variables in Creation Order
|1||subj||Num||8||11.||11.||patient ID number|
|3||SYM_1||Num||8||SYMPTSEV.||4.||severity of urinary symptoms|
Besides the variable names, this list tells us that the sym_1 variable has a permanent format called symptsev. associated with it. You might recall that if we don't have access to the permanent formats catalog — which we don't — then we'll run into trouble when trying to use the sym_1 variable. That's why we specified the NOFMTERR option before trying to use the analysis data set. The NOFMTERR option allows us to use the analysis data set. We just can't take advantage of its variables' permanent formats.
Perhaps you'd appreciate an explanation of what the four variables are? Here goes:
- subj: subject ID number
- ctr: clinical center number (1, 2, 3, 4, 5)
- cyst_hb: indicates whether or not a hydrodistention and/or biopsy was performed (0 = a local cystoscopy with no hydrodistention or biopsy, 1 = hydrodistention and biopsy, and 2 = hydrodistention only)
- sym_1: which indicates the subject's general assessment of the severity of his/her urinary symptoms (1 = not severe at all to 5 = extremely severe)
It might also help to review the first 15 observations just to get a feel for what the data look like:
The Analysis data set
Now, as promised, let's use the analysis data set to illustrate some of the statistical tests and measures of association you can request from SAS while using the FREQ procedure.
Some clinical centers may be more likely to perform a cystoscopy (which is a fairly invasive procedure) on their patients than other clinical centers. One could imagine this happening for a variety of reasons. For instance, one clinical center might have more severe patients thereby justifying more invasive procedures. Or perhaps the patients attending a particular clinical center might be better off financially and therefore more willing to pay for additional procedures. In any case, suppose we are interested in testing whether or not there is an association between performing a cystoscopy (cyst_hb) and clinical center (ctr). A chi-square test between the two variables would help us answer our research question. The following FREQ procedure illustrates the use of the CHISQ tables option in order to obtain the value of the chi-square test statistic and its associated P-value (as well as a few other useful statistics and P-values):
PROC FORMAT; value cystfmt 0 = 'Local' 1 = 'Both' 2 = 'Hydro' OTHER = 'Nothing'; RUN; PROC FREQ data=icdb.analysis; title 'Chi-square Test of Hospital and Cystoscopy Procedure: CHISQ'; format cyst_hb cystfmt.; tables ctr*cyst_hb/nopercent nocol missing chisq; RUN;
Of course, the FORMAT procedure and the FORMAT statement that appears in the FREQ procedure are used just to make the displayed values of the cyst_hb variables more meaningful to us.
The TABLES statement first requests a two-way table between the (row) variable ctr and the (column) variable cyst_hb. Because we are interested in including the missing values ("Nothing") in the analysis, we include the MISSING tables option. When doing this kind of analysis, I like to use the NOPERCENT and NOCOL tables options to help declutter the two-way frequency table. Finally, the CHISQ tables option tells SAS to calculate the chi-square statistics and its P-value (as well as a few other statistics).
Launch and run the SAS program, and review the resulting output. You should first see a two-way table (with five rows for ctr and four columns for cyst_hb). Then, you should see a list of six different statistics, of which the first one is the chi-square test statistic. Here, the value of the statistic is 77.2 (rounded) with 12 degrees of freedom (DF) and a P-value that is less than 0.0001. (Assuming that there is enough non-missing data and therefore that the chi-square test is valid), the P-value tells us that it is highly unlikely that we would observe the data we did under the assumption that ctr and cyst_hb are not associated. Therefore, we conclude that ctr and cyst_hb are associated.
If we are interested in quantifying the association between clinical center and performing a cystoscopy, then we would want to take advantage of the MEASURES tables option. The following FREQ procedure illustrates the use of the MEASURES tables option to obtain a basic set of measures of association and their standard errors:
PROC FORMAT; value cystfmt 0 = 'Local' 1 = 'Both' 2 = 'Hydro' OTHER = 'Nothing'; RUN; PROC FREQ data=icdb.analysis; title 'Chi-square Test of Hospital and Cystoscopy Procedure: MEASURES'; format cyst_hb cystfmt.; tables ctr*cyst_hb/nopercent nocol missing measures; RUN;
Again, the FORMAT procedure and the FORMAT statement that appears in the FREQ procedure are used just to make the displayed values of the cyst_hb variables more meaningful to us.
Launch and run the SAS program, and review the resulting output. You should again first see a two-way table (with five rows for ctr and four columns for cyst_hb):
Chi-square Test of Hospital and Cystoscopy Procedure: MEASURES
The FREQ Procedure
Table of ctr by CYST_HB
Then, you should see a list of thirteen different statistics lumped into five groups:
Statistics for Table of ctr by CYST_HB
|Somers' D C|R||0.0870||0.0276|
|Somers' D R|C||0.1318||0.0417|
|Lambda Asymmetric C|R||0.0000||0.0000|
|Lambda Asymmetric R|C||0.0155||0.0267|
|Uncertainty Coefficient C|R||0.0802||0.0133|
|Uncertainty Coefficient R|C||0.0455||0.0079|
|Uncertainty Coefficient Symmetric||0.0581||0.0099|
The first statistic is Gamma, the second is Kendall's Tau-b, ..., and the last is Uncertainty Coefficient Symmetric. The column labeled "Value" is the value calculated for the given statistic for this data set, and the column labeled "ASE" is the calculated (asymptotic) standard error of the statistic.
The Cochran-Mantel-Haenszel test allows us to test for the association between two categorical variables while adjusting for a third categorical variable. To request that SAS performs such a test, we must use the CMH tables option. The following CMH tables option requests the Cochran-Mantel-Haenszel to test for association between the two variables cyst_hb and sym_1 while adjusting for the third variable ctr:
OPTIONS NOFMTERR; PROC FORMAT; value cystfmt 0 = 'Local' 1 = 'Both' 2 = 'Hydro' OTHER = 'Nothing'; RUN; PROC FREQ data=icdb.analysis; title 'Chi-square Test of Hospital and Cystoscopy Procedure: CMH'; title2 'Adjusting for Ctr'; format cyst_hb cystfmt.; tables ctr*cyst_hb*sym_1/nopercent nocol cmh; RUN;
As always, we put the stratifying variable — in this case, ctr — in the first position of the tables statement. Then, we put the two variables between which we are testing for association — in this case, cyst_hb and sym_1 — in the second and third positions. Again, the NOPERCENT and NOCOL tables options are used to help declutter the resulting frequency tables. Finally, the CMH tables option gives us the Cochran-Mantel-Haenszel test for association.
Launch and run the SAS program, and review the resulting output. You should first see a set of five two-way tables (one for each level of ctr). Here's what the table looks like for ctr = 2:
Table 2 of CYST_HB by SYM_1
Controlling for ctr=2
|CYST_HB||SYM_1 (severity of urinary symptoms)|
Then, you should see a set of three Cochran-Mantel-Haenszel statistics — the first one is labeled Nonzero Correlation, the second one is labeled Row Mean Scores Differ, and the third one is labeled General Association:
Chi-square test of Hospital and Cystoscopy Procedure: CMH
Adjusting for Ctr
The FREQ Procedure
Summary Statistics for CYST_HB by SYM_1
Controlling for ctr
Cochran-Mantel-Haenszel Statistics (Based on Table Scores)
|2||Row Mean Scores Differ||2||2.9560||0.2281|
The column labeled "DF" contains the given statistic's degrees of freedom, the column labeled "Value" contains the value calculated for the given statistic for the data set, and the column labeled "Prob" contains the statistic's P-value.