This example uses the SIS_Survey data set from the section 'Getting Started' on page 4185. The data set contains results from a customer satisfaction survey for a student information system (SIS).
The following PROC SURVEYFREQ statements request a two-way table for the variables Department by Response and customize the crosstabulation table display.
proc surveyfreq data=SIS_Survey; tables Department * Response / cv deff nowt nostd nototal; strata State NewUser / list; cluster School; weight SamplingWeight; run;
The TABLES statement requests a two-way table of Department by Response . The CV option requests coefficients of variation for the percentage estimates. The DEFF option requests design effects for the percentage estimates. The NOWT option suppresses display of the weighted frequencies, and the NOSTD option suppresses display of standard errors for the estimates. The NOTOTAL option suppresses the row totals, column totals, and overall totals.
The WCHISQ option requests a Wald chi-square test of association between the variables Department and Response .
The STRATA, CLUSTER, and WEIGHT statements provide sample design information to the procedure, so that the analysis will be done according to the sample design used for the survey. The STRATA statement names the variables State and NewUser , which identify the first-stage strata. The LIST option in the STRATA statement requests a Stratum Information table. The CLUSTER statement identifies School as the cluster or first-stage sampling unit. The WEIGHT statement names the sampling weight variable.
Output 68.1.1 displays the Data Summary and Stratum Information tables produced by PROC SURVEYFREQ. The Stratum Information table lists the six strata in the survey and shows the number of clusters, or schools , and the number of observations in each stratum.
School Information System Survey The SURVEYFREQ Procedure Data Summary Number of Strata 6 Number of Clusters 370 Number of Observations 1850 Sum of Weights 38899.6482 Stratum Information Stratum Number of Number of Index State NewUser Obs Clusters -------------------------------------------------------------- 1 GA Renewal Customer 315 63 2 GA New Customer 355 71 3 NC Renewal Customer 280 56 4 NC New Customer 420 84 5 SC Renewal Customer 210 42 6 SC New Customer 270 54 --------------------------------------------------------------
Output 68.1.2 displays the two-way table of Department by Response . According to the TABLES statement options specified, this two-way table includes coefficients of variation and design effects for the percentage estimates, and it does not show the weighted frequencies or the standard errors of the estimates.
School Information System Survey The SURVEYFREQ Procedure Table of Department by Response CV for Design Department Response Frequency Percent Percent Effect ------------------------------------------------------------------------------- Faculty Very Unsatisfied 209 13.4987 0.0865 2.1586 Unsatisfied 203 13.0710 0.0868 2.0962 Neutral 346 22.4127 0.0629 2.1157 Satisfied 254 16.2006 0.0806 2.3232 Very Satisfied 98 6.2467 0.1362 2.2842 ------------------------------------------------------------------------------- Admin/Guidance Very Unsatisfied 95 3.6690 0.1277 1.1477 Unsatisfied 123 4.6854 0.1060 1.0211 Neutral 235 9.1838 0.0700 0.9166 Satisfied 201 7.7305 0.0756 0.8848 Very Satisfied 86 3.3016 0.1252 0.9892 -------------------------------------------------------------------------------
The following PROC SURVEYFREQ statements request a two-way table of Department by Response that includes row percentages, and also a Wald chi-square test of association between the two table variables.
proc surveyfreq data=SIS_Survey nosummary; tables Department * Response / row nowt wchisq; strata State NewUser; cluster School; weight SamplingWeight; run;
Output 68.1.3 displays the two-way table. The row percentages show the distribution of Response for Department = 'Faculty' and for Department = 'Admin/Guidance'.
School Information System Survey The SURVEYFREQ Procedure Table of Department by Response Std Err of Row Std Err of Department Response Frequency Percent Percent Percent Row Percent --------------------------------------------------------------------------------------------------- Faculty Very Unsatisfied 209 13.4987 1.1675 18.8979 1.6326 Unsatisfied 203 13.0710 1.1350 18.2992 1.5897 Neutral 346 22.4127 1.4106 31.3773 1.9705 Satisfied 254 16.2006 1.3061 22.6805 1.8287 Very Satisfied 98 6.2467 0.8506 8.7452 1.1918 Total 1110 71.4297 0.1468 100.000 --------------------------------------------------------------------------------------------------- Admin/Guidance Very Unsatisfied 95 3.6690 0.4684 12.8419 1.6374 Unsatisfied 123 4.6854 0.4966 16.3995 1.7446 Neutral 235 9.1838 0.6430 32.1447 2.2300 Satisfied 201 7.7305 0.5842 27.0579 2.0406 Very Satisfied 86 3.3016 0.4133 11.5560 1.4466 Total 740 28.5703 0.1468 100.000 --------------------------------------------------------------------------------------------------- Total Very Unsatisfied 304 17.1676 1.2872 Unsatisfied 326 17.7564 1.2712 Neutral 581 31.5965 1.5795 Satisfied 455 23.9311 1.4761 Very Satisfied 184 9.5483 0.9523 Total 1850 100.000 ---------------------------------------------------------------------------------------------------
Output 68.1.4 displays the Wald chi-square test for association between Department and Response . The Wald chi-square is 11.44, and the corresponding adjusted F value is 2.84 with a p -value of .0243. This indicates a significant association between department (faculty or admin/guidance) and satisfaction with the student information system.
Table of Department by Response Wald Chi-Square Test Chi-Square 11.4454 F Value 2.8613 Num DF 4 Den DF 364 Pr > F 0.0234 Adj F Value 2.8378 Num DF 4 Den DF 361 Pr > Adj F 0.0243 Sample Size = 1850
Continuing to use the SIS_Survey data set from the section 'Getting Started' on page 4185, this example shows how to produce multiway tables. The following PROC SURVEYFREQ statements request a table of Department by SchoolType by Response for the student information system survey.
proc surveyfreq data=SIS_Survey; tables Department * SchoolType * Response SchoolType * Response; strata State NewUser; cluster School; weight SamplingWeight; run;
The TABLES statement requests a multiway table with SchoolType as the row variable, Response as the column variable, and Department as the layer variable. This request produces a separate two-way table of SchoolType by Response for each level of the variable Department . The TABLES statement also requests a two-way table of SchoolType by Response , which totals the multiway table over both levels of Department . As in the previous examples, the STRATA, CLUSTER, and WEIGHT statements provide sample design information, so that the analysis will be done according to the design used for this survey.
Output 68.2.1 displays the multiway table produced by PROC SURVEYFREQ, which includes a table of SchoolType by Response for Department = 'Faculty' and for Department = 'Admin/Guidance'.
School Information System Survey The SURVEYFREQ Procedure Table of SchoolType by Response Controlling for Department=Faculty Weighted Std Dev of Std Err of SchoolType Response Frequency Frequency Wgt Freq Percent Percent ---------------------------------------------------------------------------------------------------- Middle School Very Unsatisfied 74 1846 301.22637 6.6443 1.0838 Unsatisfied 78 1929 283.11476 6.9428 1.0201 Neutral 130 3289 407.80855 11.8369 1.4652 Satisfied 113 2795 368.85087 10.0597 1.3288 Very Satisfied 55 1378 261.63311 4.9578 0.9411 Total 450 11237 714.97120 40.4415 2.5713 ---------------------------------------------------------------------------------------------------- High School Very Unsatisfied 135 3405 389.42313 12.2536 1.3987 Unsatisfied 125 3155 384.56734 11.3563 1.3809 Neutral 216 5429 489.37826 19.5404 1.7564 Satisfied 141 3507 417.54773 12.6208 1.5040 Very Satisfied 43 1052 221.59367 3.7874 0.7984 Total 660 16549 719.61536 59.5585 2.5713 ---------------------------------------------------------------------------------------------------- Total Very Unsatisfied 209 5251 454.82598 18.8979 1.6326 Unsatisfied 203 5085 442.39032 18.2992 1.5897 Neutral 346 8718 550.81735 31.3773 1.9705 Satisfied 254 6302 507.01711 22.6805 1.8287 Very Satisfied 98 2430 330.97602 8.7452 1.1918 Total 1110 27786 119.25529 100.000 ---------------------------------------------------------------------------------------------------- Table of SchoolType by Response Controlling for Department=Admin/Guidance Weighted Std Dev of Std Err of SchoolType Response Frequency Frequency Wgt Freq Percent Percent ---------------------------------------------------------------------------------------------------- Middle School Very Unsatisfied 42 649.43427 133.06194 5.8435 1.1947 Unsatisfied 31 460.35557 100.80158 4.1422 0.9076 Neutral 104 1568 186.99946 14.1042 1.6804 Satisfied 84 1269 165.71127 11.4142 1.4896 Very Satisfied 39 574.93878 110.37243 5.1732 0.9942 Total 300 4521 287.86832 40.6774 2.5801 ---------------------------------------------------------------------------------------------------- High School Very Unsatisfied 53 777.77725 136.41869 6.9983 1.2285 Unsatisfied 92 1362 175.40862 12.2573 1.5806 Neutral 131 2005 212.34804 18.0404 1.8990 Satisfied 117 1739 190.07798 15.6437 1.7118 Very Satisfied 47 709.37033 126.54394 6.3828 1.1371 Total 440 6593 288.92483 59.3226 2.5801 ---------------------------------------------------------------------------------------------------- Total Very Unsatisfied 95 1427 182.28132 12.8419 1.6374 Unsatisfied 123 1823 193.43045 16.3995 1.7446 Neutral 235 3572 250.22739 32.1447 2.2300 Satisfied 201 3007 226.82311 27.0579 2.0406 Very Satisfied 86 1284 160.83434 11.5560 1.4466 Total 740 11114 60.78850 100.000 ----------------------------------------------------------------------------------------------------
PROC SURVEYFREQ uses the Output Delivery System (ODS) to create output data sets. This is a departure from older SAS procedures that provide OUTPUT statements for similar functionality. Using ODS, you can create a SAS data set from any piece of PROC SURVEYFREQ output. For more information on ODS, see Chapter 14, 'Using the Output Delivery System.'
When selecting tables for ODS output data set, you reference tables by their ODS table names. Each table created by PROC SURVEYFREQ is assigned a name , and the section 'ODS Table Names' on page 4230 lists the table names.
To save the one-way table of Response from Figure 68.3 in an output data set, use an ODS OUTPUT statement as follows :
proc surveyfreq data=SIS_Survey; tables Response / cl nowt; ods output OneWay=ResponseTable; strata State NewUser; cluster School; weight SamplingWeight; run;
Output 68.3.1 displays the output data set ResponseTable , which contains the one-way table of Response . This data set has six observations, and each of these observations corresponds to a row of the one-way table. The first five observations correspond to the five levels of Response , as they are ordered in the display, and the last observation corresponds to the overall total, which is the last row of the table. The data set ResponseTable includes a variable corresponding to each column of the one-way table. For example, the variable Percent contains the percentage estimates, and the variables LowerCL and UpperCL contain the lower and upper confidence limits for the percentage estimates.
Obs Table Response Frequency Percent StdErr LowerCL UpperCL 1 Table Response Very Unsatisfied 304 17.1676 1.2872 14.6364 19.6989 2 Table Response Unsatisfied 326 17.7564 1.2712 15.2566 20.2562 3 Table Response Neutral 581 31.5965 1.5795 28.4904 34.7026 4 Table Response Satisfied 455 23.9311 1.4761 21.0285 26.8338 5 Table Response Very Satisfied 184 9.5483 0.9523 7.6756 11.4210 6 Table Response . 1850 100.000 _ _ _
PROC SURVEYFREQ also creates a table summary that is not displayed. Some of the information in this table is similar to that contained in the 'Data Summary' table, but the table summary describes data used to analyze the specified table, while the data summary describes the entire input data set. Due to missing values, for example, the number of observations (or strata or clusters) used to analyze a particular table may differ from the number of observations (or strata or clusters) reported for the input data set in the 'Data Summary' table. See the section 'Missing Values' on page 4205 for more details. If you request confidence limits, the 'Table Summary' table also contains the degrees of freedom and the t -value used to compute the confidence limits.
The following statements store the nondisplayed 'Table Summary' table in the output data set ResponseSummary .
proc surveyfreq data=SIS_Survey; tables Response / cl nowt; ods output TableSummary=ResponseSummary; strata State NewUser; cluster School; weight SamplingWeight; run;
Output 68.3.2 displays the output data set ResponseSummary .
Number Number Degrees Number of of of of t Obs Table Observations Strata Clusters Freedom Percentile 1 Table Response 1850 6 370 364 1.966503