Chapter Contents

Previous

Next
The REPORT Procedure

Example 3: Using Aliases to Obtain Multiple Statistics for the Same Variable


Procedure features:
COLUMN statement:
with aliases
COMPUTE statement arguments:
AFTER
DEFINE statement options:
ANALYSIS
MAX
MIN
NOPRINT
customizing column headers
LINE statement:
pointer controls
quoted text
repeating a character string
variable values and formats
writing a blank line
Other features:
automatic macro variables:
SYSDATE
Data set: GROCERY
Formats: $MGRFMT. and $DEPTFMT.

The customized summary at the end of this report displays the minimum and maximum values of Sales over all departments for stores in the southeast sector. To determine these values, PROC REPORT needs the MIN and MAX statistic for Sales in every row of the report. However, to keep the report simple, the display of these statistics is suppressed.





Program

libname proclib 'SAS-data-library';
options nodate pageno=1 linesize=64 pagesize=60
        fmtsearch=(proclib);
 Note about code
proc report data=grocery nowd headline headskip;
 Note about code
   column manager department sales
          sales=salesmin
          sales=salesmax;
 Note about code
   define manager / order
                    order=formatted
                    format=$mgrfmt.
                    'Manager';
   define department    / order
                    order=internal
                    format=$deptfmt.
                    'Department';
 Note about code
   define sales / analysis sum format=dollar7.2 'Sales';
 Note about code
   define salesmin / analysis min noprint;
   define salesmax / analysis max noprint;
 Note about code
   compute after;
      line ' ';
      line @7 53*'-';
 Note about code
      line @7 '| Departmental sales ranged from'
           salesmin dollar7.2  +1 'to' +1 salesmax dollar7.2
           '. |';
      line @7 53*'-';
 Note about code
   endcomp;
 Note about code
   where sector='se';
   title 'Sales for the Southeast Sector';
   title2 "for &sysdate";
run;


Output

                 Sales for the Southeast Sector                1
                          for 27MAY98

                  Manager  Department    Sales
                  ----------------------------
                                              
                  Jones    Paper        $40.00
                           Canned      $220.00
                           Meat/Dairy  $300.00
                           Produce      $70.00
                  Smith    Paper        $50.00
                           Canned      $120.00
                           Meat/Dairy  $100.00
                           Produce      $80.00
                                                                
      -----------------------------------------------------     
      | Departmental sales ranged from $40.00 to $300.00. |     
      -----------------------------------------------------     


Chapter Contents

Previous

Next

Top of Page

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