MEANS Procedure

Example 10: Computing Output Statistics with Missing Class Variable Values

Features:
PROC MEANS statement options:
CHARTYPE
NOPRINT
NWAY
CLASS statement options:
ASCENDING
MISSING
ORDER=

OUTPUT statement

Other features:

PRINT procedure

Data set: CAKE

Details

This example does the following:
  • suppresses the display of PROC MEANS output
  • considers missing values as valid level values for only one class variable
  • orders observations in the output data set by the ascending frequency for a single class variable
  • stores observations for only the highest _TYPE_ value
  • stores _TYPE_ as binary character values
  • stores the maximum taste score in a new variable
  • displays the output data set

Program

options nodate pageno=1 linesize=80 pagesize=60;
proc means data=cake chartype nway noprint;
   class flavor /order=freq ascending;
   class layers /missing;
   var TasteScore;
   output out=cakestat max=HighScore;
run;
proc print data=cakestat;
   title 'Maximum Taste Score for Flavor and Cake Layers';
run;

Program Description

Set the SAS system options. The NODATE option suppresses the display of the date and time in the output. PAGENO= specifies the starting page number. LINESIZE= specifies the output line length, and PAGESIZE= specifies the number of lines on an output page.
options nodate pageno=1 linesize=80 pagesize=60;
Specify the analysis options. NWAY prints observations with the highest _TYPE_ value. NOPRINT suppresses the display of all PROC MEANS output.
proc means data=cake chartype nway noprint;
Specify subgroups for the analysis. The CLASS statements separate the analysis by Flavor and Layers. ORDER=FREQ and ASCENDING order the levels of Flavor by ascending frequency. MISSING uses missing values of Layers as a valid class level value.
   class flavor /order=freq ascending;
   class layers /missing;
Specify the analysis variable. The VAR statement specifies that PROC MEANS calculate statistics on the TasteScore variable.
   var TasteScore;
Specify the output data set options. The OUTPUT statement creates the CAKESTAT data set and outputs the maximum value for the taste score to the new variable HighScore.
   output out=cakestat max=HighScore;
run;
Print the output data set WORK.CAKESTAT.
proc print data=cakestat;
   title 'Maximum Taste Score for Flavor and Cake Layers';
run;

Output

The CAKESTAT output data set contains only observations for the combination of the two class variables, Flavor and Layers. Therefore, the value of _TYPE_ is 11 for all observations. The observations are ordered by ascending frequency of Flavor. The missing value in Layers is a valid value for this class variable. PROC MEANS excludes the observation with the missing flavor because it is an invalid value for Flavor.
Maximum Taste Score
Maximum Taste Score for Flavor and Cake Layers