Previous Page | Next Page

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 headings

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

 Note about code
libname proclib 'SAS-library';
 Note about code
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*'-';
   endcomp;
 Note about code
   where sector='se';
 Note about code
   title 'Sales for the Southeast Sector';
   title2 "for &sysdate";
run;

Output

                 Sales for the Southeast Sector                1
                          for 04JAN02

                  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. |     
      -----------------------------------------------------     

Previous Page | Next Page | Top of Page