Previous Page | Next Page

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 heading is the formatted value of the variable.


Program

 Note about code
libname proclib 'SAS-library';
 Note about code
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

                  Sales Summary for All Stores                 1

                                                          
               Nonperishable     Perishable               
      Manager          Sales          Sales          Sales
      ----------------------------------------------------
                                                          
      Adams          $265.00        $430.00        $695.00
      Alomar         $510.00        $276.00        $786.00
      Andrews        $620.00        $425.00      $1,045.00
      Brown          $275.00        $323.00        $598.00
      Jones          $260.00        $370.00        $630.00
      Pelfrey        $465.00        $281.00        $746.00
      Reveiz         $480.00        $630.00      $1,110.00
      Smith          $170.00        $180.00        $350.00
      Taylor         $173.00        $180.00        $353.00
                                                                
          Total sales for these stores were: $6,313.00          

Previous Page | Next Page | Top of Page