The SURVEYFREQ Procedure

Example 94.3 Output Data Sets

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. By using ODS, you can create a SAS data set from any piece of PROC SURVEYFREQ output. For more information about ODS, see Chapter 20: Using the Output Delivery System.

When selecting tables for ODS output data sets, you refer to tables by their ODS table names. Each table created by PROC SURVEYFREQ is assigned a name. See the section ODS Table Names for a list of the table names provided by PROC SURVEYFREQ.

To save the one-way table of Response from Figure 94.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 94.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 one-way table display, and the last observation corresponds to the overall total, which is the last row of the one-way 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.

Output 94.3.1: ResponseTable Output Data Set

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 the data that are 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 can 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 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 94.3.2 displays the output data set ResponseSummary.

Output 94.3.2: ResponseSummary Output Data Set

Obs Table Number of Observations Number of Strata Number of Clusters Degrees of Freedom t Percentile
1 Table Response 1850 6 370 364 1.966503