Chapter Contents

Previous

Next
The REPORT Procedure

Example 14: Using a Format to Create Groups


Procedure features:
DEFINE statement options:
GROUP
Other features: FORMAT procedure
Data set: GROCERY
Formats: $MGRFMT.

This example shows how to use formats to control the number of groups that PROC REPORT creates. The program creates a format for Department that classifies the four departments as one of two types: perishable or nonperishable. Consequently, when Department is an across variable, PROC REPORT creates only two columns instead of four. The column header is the formatted value of the variable.


Program

libname proclib 'SAS-data-library';
options nodate pageno=1 linesize=64 pagesize=60
        fmtsearch=(proclib);
 Note about code
proc format;
   value $perish 'p1','p2'='Perishable'
                'np1','np2'='Nonperishable';
run;
 Note about code
proc report data=grocery nowd
     headline
     headskip;
 Note about code
   column manager department,sales sales;
 Note about code
   define manager / group order=formatted
                    format=$mgrfmt.;
   define department / across order=formatted
                 format=$perish. '';
 Note about code
   define sales / analysis sum
                  format=dollar9.2 width=13;
 Note about code
   compute after;
      line ' ';
      line 'Total sales for these stores were: '
            sales.sum dollar9.2;
   endcomp;
 Note about code
title 'Sales Summary for All Stores';
run;


Output
[HTML Output]  [Listing Output]


Chapter Contents

Previous

Next

Top of Page

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