The SURVEYFREQ Procedure

Getting Started: SURVEYFREQ Procedure

(View the complete code for this example.)

The following example shows how you can use PROC SURVEYFREQ to analyze sample survey data. The example uses data from a customer satisfaction survey for a student information system (SIS), which is a software product that provides modules for student registration, class scheduling, attendance, grade reporting, and other functions.

The software company conducted a survey of school personnel who use the SIS. A probability sample of SIS users was selected from the study population, which included SIS users at middle schools and high schools in the three-state area of Georgia, South Carolina, and North Carolina. The sample design for this survey was a two-stage stratified design. A first-stage sample of schools was selected from the list of schools in the three-state area that use the SIS. The list of schools (the first-stage sampling frame) was stratified by state and by customer status (whether the school was a new user of the system or a renewal user). Within the first-stage strata, schools were selected with probability proportional to size and with replacement, where the size measure was school enrollment. From each sample school, five staff members were randomly selected to complete the SIS satisfaction questionnaire. These staff members included three teachers and two administrators or guidance department members.

The SAS data set SIS_Survey contains the survey results and the sample design information needed to analyze the data. This data set includes an observation for each school staff member responding to the survey. The variable Response contains the staff member’s response about overall satisfaction with the system.

The variable State contains the school’s state, and the variable NewUser contains the school’s customer status ('New Customer' or 'Renewal Customer'). These two variables determine the first-stage strata from which schools were selected. The variable School contains the school identification code and identifies the first-stage sampling units (clusters). The variable SamplingWeight contains the overall sampling weight for each respondent. Overall sampling weights were computed from the selection probabilities at each stage of sampling and were adjusted for nonresponse.

Other variables in the data set SIS_Survey include SchoolType and Department. The variable SchoolType identifies the school as a high school or a middle school. The variable Department identifies the staff member as a teacher, or an administrator or guidance department member.

The following PROC SURVEYFREQ statements request a one-way frequency table for the variable Response:

title 'Student Information System Survey';
proc surveyfreq data=SIS_Survey;
   tables  Response;
   strata  State NewUser;
   cluster School;
   weight  SamplingWeight;
run;

The PROC SURVEYFREQ statement invokes the procedure and identifies the input data set to be analyzed. The TABLES statement requests a one-way frequency table for the variable Response. The table request syntax for PROC SURVEYFREQ is very similar to the table request syntax for PROC FREQ. This example shows a request for a single one-way table, but you can also request two-way tables and multiway tables. As in PROC FREQ, you can request more than one table in the same TABLES statement, and you can use multiple TABLES statements in the same invocation of the procedure.

The STRATA, CLUSTER, and WEIGHT statements provide sample design information for the procedure, so that the analysis is done according to the sample design used for the survey, and the estimates apply to the study population. The STRATA statement names the variables State and NewUser, which identify the first-stage strata. The design for this example also includes stratification at the second stage of selection (by type of school personnel), but you specify only the first-stage strata for PROC SURVEYFREQ. The CLUSTER statement names the variable School, which identifies the clusters (primary sampling units). The WEIGHT statement names the sampling weight variable.

Figure 112.1 and Figure 112.2 display the output produced by PROC SURVEYFREQ, which includes the "Data Summary" table and the one-way table, "Table of Response." The "Data Summary" table is produced by default unless you specify the NOSUMMARY option. This table shows there are 6 strata, 370 clusters or schools, and 1850 observations (respondents) in the SIS_Survey data set. The sum of the sampling weights is approximately 39,000, which estimates the total number of school personnel in the study area that use the SIS.

Figure 112.1: SIS_Survey Data Summary

Student Information System Survey

The SURVEYFREQ Procedure

Data Summary
Number of Strata6
Number of Clusters370
Number of Observations1850
Sum of Weights38899.6482


Figure 112.2 displays the one-way table of Response, which provides estimates of the population total (weighted frequency) and the population percentage for each category (level) of the variable Response. The response level 'Very Unsatisfied' has a frequency of 304, which means that 304 sample respondents fall into this category. It is estimated that 17.17% of all school personnel in the study population fall into this category, and the standard error of this estimate is 1.29%. The estimates apply to the population of all SIS users in the study area, as opposed to describing only the sample of 1850 respondents. The estimate of the total number of school personnel that are 'Very Unsatisfied' is 6,678, with a standard deviation of 502. The standard errors computed by PROC SURVEYFREQ are based on the multistage stratified design of the survey. This differs from some of the traditional analysis procedures, which assume the design is simple random sampling from an infinite population.

Figure 112.2: One-Way Table of Response

Table of Response
ResponseFrequencyWeighted
Frequency
Std Err of
Wgt Freq
PercentStd Err of
Percent
Very Unsatisfied3046678501.6103917.16761.2872
Unsatisfied3266907495.9410117.75641.2712
Neutral58112291617.2014731.59651.5795
Satisfied4559309572.2786823.93111.4761
Very Satisfied1843714370.665779.54830.9523
Total185038900129.85268100.0000 


The following PROC SURVEYFREQ statements request confidence limits for the percentages, a chi-square goodness-of-fit test, and a weighted frequency plot for the one-way table of Response. The ODS GRAPHICS ON statement enables ODS Graphics.

title 'Student Information System Survey';
ods graphics on;
proc surveyfreq data=SIS_Survey nosummary;
   tables  Response / clwt nopct chisq
                      plots=WtFreqPlot;
   strata  State  NewUser;
   cluster School;
   weight  SamplingWeight;
run;
ods graphics off;

The NOSUMMARY option in the PROC SURVEYFREQ statement suppresses the "Data Summary" table. In the TABLES statement, the CLWT option requests confidence limits for the weighted frequencies (totals). The NOPCT option suppresses display of the weighted frequencies and their standard deviations. The CHISQ option requests a Rao-Scott chi-square goodness-of-fit test, and the PLOTS= option requests a weighted frequency plot. ODS Graphics must be enabled before producing plots.

Figure 112.3 shows the one-way table of Response, which includes confidence limits for the weighted frequencies. The 95% confidence limits for the total number of users that are 'Very Unsatisfied' are 5692 and 7665. You can change the confidence level by specifying the ALPHA= option; by default, ALPHA=0.05, which produces 95% confidence limits. Like the other estimates and standard errors produced by PROC SURVEYFREQ, these confidence limit computations take into account the complex survey design and apply to the entire study population.

Figure 112.3: Confidence Limits for Response Totals

Student Information System Survey

The SURVEYFREQ Procedure

Table of Response
ResponseFrequencyWeighted
Frequency
Std Err of
Wgt Freq
95% Confidence Limits
for Wgt Freq
Very Unsatisfied3046678501.6103956927665
Unsatisfied3266907495.9410159327882
Neutral58112291617.201471107713505
Satisfied4559309572.27868818410435
Very Satisfied1843714370.6657729854443
Total185038900129.852683864439155


Figure 112.4 displays the weighted frequency plot of Response. The plot displays weighted frequencies (totals) together with their confidence limits in the form of a vertical bar chart. You can use the PLOTS= option to request a dot plot instead of a bar chart or to plot percentages instead of weighted frequencies.

Figure 112.4: Bar Chart of Response Totals

 Bar Chart of  Totals


Figure 112.5 shows the chi-square goodness-of-fit results for the table of Response. The null hypothesis for this test is equal proportions for the levels of the one-way table. (To test a null hypothesis of specified proportions instead of equal proportions, you can use the TESTP= option to specify null hypothesis proportions.)

The chi-square test provided by the CHISQ option is the Rao-Scott design-adjusted chi-square test, which takes the sample design into account and provides inferences for the study population. To produce the Rao-Scott chi-square statistic, PROC SURVEYFREQ first computes the usual Pearson chi-square statistic based on the weighted frequencies, and then adjusts this value by using a design correction. An F approximation is also provided. For the table of Response, the F value is 30.0972 with a p-value of <0.0001, which indicates rejection of the null hypothesis of equal proportions for all response levels.

Figure 112.5: Chi-Square Goodness-of-Fit Test for Response

Rao-Scott Chi-Square Test
Pearson Chi-Square251.8105
Design Correction2.0916
  
Rao-Scott Chi-Square120.3889
DF4
Pr > ChiSq<.0001
  
F Value30.0972
Num DF4
Den DF1456
Pr > F<.0001
Sample Size = 1850


Continuing to analyze the SIS_Survey data, the following PROC SURVEYFREQ statements request a two-way table of SchoolType by Response:

title 'Student Information System Survey';
ods graphics on;
proc surveyfreq data=SIS_Survey nosummary;
   tables  SchoolType * Response /
      plots=wtfreqplot(type=dot scale=percent groupby=row);
   strata  State NewUser;
   cluster School;
   weight  SamplingWeight;
run;
ods graphics off;

The STRATA, CLUSTER, and WEIGHT statements do not change from the one-way table analysis, because the sample design and the input data set are the same. These SURVEYFREQ statements request a different table but specify the same sample design information.

The ODS GRAPHICS ON statement enables ODS Graphics. The PLOTS= option in the TABLES statement requests a plot of SchoolType by Response, and the TYPE=DOT plot-option specifies a dot plot instead of the default bar chart. The SCALE=PERCENT plot-option requests a plot of percentages instead of totals. The GROUPBY=ROW plot-option groups the graph cells by the row variable (SchoolType).

Figure 112.6 shows the two-way table produced for SchoolType by Response. The first variable named in the two-way table request, SchoolType, is referred to as the row variable, and the second variable, Response, is referred to as the column variable. Two-way tables display all column variable levels for each row variable level. This two-way table lists all levels of the column variable Response for each level of the row variable SchoolType, 'Middle School' and 'High School'. Also SchoolType = 'Total' shows the distribution of Response overall for both types of schools. And Response = 'Total' provides totals over all levels of response, for each type of school and overall. To suppress these totals, you can specify the NOTOTAL option.

Figure 112.6: Two-Way Table of SchoolType by Response

Student Information System Survey

The SURVEYFREQ Procedure

Table of SchoolType by Response
SchoolTypeResponseFrequencyWeighted
Frequency
Std Err of
Wgt Freq
PercentStd Err of
Percent
Middle SchoolVery Unsatisfied1162496351.438346.41550.9030
 Unsatisfied1092389321.979576.14270.8283
 Neutral2344856504.2055312.48471.2953
 Satisfied1974064443.7118810.44671.1417
 Very Satisfied941952302.171445.01930.7758
 Total75015758100040.50892.5691
High SchoolVery Unsatisfied1884183431.3058910.75211.1076
 Unsatisfied2174518446.3176811.61371.1439
 Neutral3477434574.1717519.11191.4726
 Satisfied2585245498.0322113.48451.2823
 Very Satisfied901762255.671584.52900.6579
 Total110023142100359.49112.5691
TotalVery Unsatisfied3046678501.6103917.16761.2872
 Unsatisfied3266907495.9410117.75641.2712
 Neutral58112291617.2014731.59651.5795
 Satisfied4559309572.2786823.93111.4761
 Very Satisfied1843714370.665779.54830.9523
 Total185038900129.85268100.0000 


Figure 112.7 displays the weighted frequency dot plot that PROC SURVEYFREQ produces for the table of SchoolType and Response. The GROUPBY=ROW plot-option groups the graph cells by the row variable (SchoolType). If you do not specify GROUPBY=ROW, the procedure groups the graph cells by the column variable by default. You can plot percentages instead of weighted frequencies by specifying the SCALE=PERCENT plot-option. You can use other plot-options to change the orientation of the plot or to request a different two-way layout.

Figure 112.7: Dot Plot of Percentages for SchoolType by Response

 Dot Plot of Percentages for  by


By default, without any other TABLES statement options, a two-way table displays the frequency, the weighted frequency and its standard deviation, and the percentage and its standard error for each table cell (combination of row and column variable levels). But there are several options available to customize your table display by adding more information or by suppressing some of the default information.

The following PROC SURVEYFREQ statements request a two-way table of SchoolType by Response that displays row percentages, and also request a chi-square test of association between the two variables:

title 'Student Information System Survey';
proc surveyfreq data=SIS_Survey nosummary;
   tables  SchoolType * Response / row nowt chisq;
   strata  State NewUser;
   cluster School;
   weight  SamplingWeight;
run;

The ROW option in the TABLES statement requests row percentages, which give the distribution of Response within each level of the row variable SchoolType. The NOWT option suppresses display of the weighted frequencies and their standard deviations. The CHISQ option requests a Rao-Scott chi-square test of association between SchoolType and Response.

Figure 112.8 displays the two-way table of SchoolType by Response. For middle schools, it is estimated that 25.79% of school personnel are satisfied with the student information system and 12.39% are very satisfied. For high schools, these estimates are 22.67% and 7.61%, respectively.

Figure 112.9 displays the chi-square test results. The Rao-Scott chi-square statistic is 9.04, and the corresponding F value is 2.26 with a p-value of 0.0605. This indicates an association between school type (middle school or high school) and satisfaction with the student information system at the 10% significance level.

Figure 112.8: Two-Way Table with Row Percentages

Student Information System Survey

The SURVEYFREQ Procedure

Table of SchoolType by Response
SchoolTypeResponseFrequencyPercentStd Err of
Percent
Row
Percent
Std Err of
Row Percent
Middle SchoolVery Unsatisfied1166.41550.903015.83731.9920
 Unsatisfied1096.14270.828315.16381.8140
 Neutral23412.48471.295330.81962.5173
 Satisfied19710.44671.141725.78862.2947
 Very Satisfied945.01930.775812.39071.7449
 Total75040.50892.5691100.0000 
High SchoolVery Unsatisfied18810.75211.107618.07351.6881
 Unsatisfied21711.61371.143919.52181.7280
 Neutral34719.11191.472632.12552.0490
 Satisfied25813.48451.282322.66631.9240
 Very Satisfied904.52900.65797.61281.0557
 Total110059.49112.5691100.0000 
TotalVery Unsatisfied30417.16761.2872  
 Unsatisfied32617.75641.2712  
 Neutral58131.59651.5795  
 Satisfied45523.93111.4761  
 Very Satisfied1849.54830.9523  
 Total1850100.0000   


Figure 112.9: Chi-Square Test of No Association

Rao-Scott Chi-Square Test
Pearson Chi-Square18.7829
Design Correction2.0766
  
Rao-Scott Chi-Square9.0450
DF4
Pr > ChiSq0.0600
  
F Value2.2613
Num DF4
Den DF1456
Pr > F0.0605
Sample Size = 1850


Last updated: February 13, 2019