When the value of the WEIGHT variable is missing, PROC FREQ does not include that observation in the analysis.
PROC FREQ treats missing BY variable values like any other BY variable value. The missing values form a separate BY group.
If an observation has a missing value for a variable in a TABLES request, by default PROC FREQ does not include that observation in the frequency or crosstabulation table. Also by default, PROC FREQ does not include observations with missing values in the computation of percentages and statistics. The procedure displays the number of missing observations below each table.
PROC FREQ also reports the number of missing values in output data sets. The TABLES statement OUT= data set includes an observation that contains the missing value frequency. The NMISS option in the OUTPUT statement provides an output data set variable that contains the missing value frequency.
The following options change the way in which PROC FREQ handles missing values of TABLES variables:
displays missing value frequencies in frequency or crosstabulation tables but does not include them in computations of percentages or statistics.
treats missing values as a valid nonmissing level for all TABLES variables. Displays missing levels in frequency and crosstabulation tables and includes them in computations of percentages and statistics.
This example shows the three ways that PROC FREQ can handle missing values of TABLES variables. The following DATA step statements
create a data set with a missing value for the variable A
:
data one; input A Freq; datalines; 1 2 2 2 . 2 ;
The following PROC FREQ statements request a one-way frequency table for the variable A
. The first request does not specify a missing value option. The second request specifies the MISSPRINT option in the TABLES
statement. The third request specifies the MISSING option in the TABLES statement.
proc freq data=one; tables A; weight Freq; title 'Default'; run; proc freq data=one; tables A / missprint; weight Freq; title 'MISSPRINT Option'; run; proc freq data=one; tables A / missing; weight Freq; title 'MISSING Option'; run;
Figure 38.12 displays the frequency tables produced by this example. The first table shows PROC FREQ’s default behavior for handling missing
values. The observation with a missing value of the TABLES variable A
is not included in the table, and the frequency of missing values is displayed below the table. The second table, for which
the MISSPRINT option is specified, displays the missing observation but does not include its frequency when computing the
total frequency and percentages. The third table shows that PROC FREQ treats the missing level as a valid nonmissing level
when the MISSING option is specified. The table displays the missing level, and PROC FREQ includes this level when computing
frequencies and percentages.
Figure 38.12: Missing Values in Frequency Tables
Default |
A | Frequency | Percent | Cumulative Frequency |
Cumulative Percent |
---|---|---|---|---|
1 | 2 | 50.00 | 2 | 50.00 |
2 | 2 | 50.00 | 4 | 100.00 |
Frequency Missing = 2 |
MISSPRINT Option |
A | Frequency | Percent | Cumulative Frequency |
Cumulative Percent |
---|---|---|---|---|
. | 2 | . | . | . |
1 | 2 | 50.00 | 2 | 50.00 |
2 | 2 | 50.00 | 4 | 100.00 |
Frequency Missing = 2 |
MISSING Option |
A | Frequency | Percent | Cumulative Frequency |
Cumulative Percent |
---|---|---|---|---|
. | 2 | 33.33 | 2 | 33.33 |
1 | 2 | 33.33 | 4 | 66.67 |
2 | 2 | 33.33 | 6 | 100.00 |
When a combination of variable values for a two-way table is missing, PROC FREQ assigns zero to the frequency count for the table cell. By default, PROC FREQ does not display missing combinations in LIST format. Also, PROC FREQ does not include missing combinations in the OUT= output data set by default. To include missing combinations, you can specify the SPARSE option with the LIST or OUT= option in the TABLES statement.