Chapter Contents

Previous

Next
The MEANS Procedure

Example 6: Using Preloaded Formats with Class Variables


Procedure features:
PROC MEANS statement options:
COMPLETETYPES
FW=
MISSING
NONOBS
CLASS statement options:
EXCLUSIVE
ORDER=
PRELOADFMT
WAYS statement
Other features
FORMAT procedure
FORMAT statement
Data set: CAKE

This example


Program

options nodate pageno=1 linesize=80 pagesize=64;
 Note about code
proc format;
   value layerfmt 1='single layer'
                  2-3='multi-layer'
                  .='unknown';
   value $flvrfmt (notsorted)
                  'Vanilla'='Vanilla'
                  'Orange','Lemon'='Citrus'
                  'Spice'='Spice'
                  'Rum','Mint','Almond'='Other Flavor';
run;
 Note about code
proc means data=cake fw=7 completetypes missing nonobs;
 Note about code
   class flavor layers/preloadfmt exclusive order=data;
 Note about code
   ways 1 2;
 Note about code
   var TasteScore;
 Note about code
   format layers layerfmt. flavor $flvrfmt.;
   title 'Taste Score For Number of Layers and Cake Flavors';
run;


Output
The one-way combination of class variables appears before the two-way combination. PROC MEANS just reports the level values that are listed in the preloaded range of user-defined formats even when the frequency of observations is zero (i.e., citrus). PROC MEANS rejects entire observations based on the exclusion of any single class value in a given observation. Therefore, when the number of layers is unknown, statistics are calculated for only one observation. The other observation is excluded because the flavor chocolate was not included in the preloaded user-defined format for Flavor.

The order of the levels is based on the order of the user-defined formats. PROC FORMAT automatically sorted the Layers format and did not sort the Flavor format.

[HTML Output]
 [Listing Output]


Chapter Contents

Previous

Next

Top of Page

Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.