Previous Page | Next Page

The REPORT Procedure

Example 5: Creating a Column for Each Value of a Variable


Procedure features:

PROC REPORT statement options:

SPLIT=

BREAK statement options:

SKIP

COLUMN statement:

stacking variables

COMPUTE statement arguments:

with a computed variable as report-item

AFTER

DEFINE statement options:

ACROSS

ANALYSIS

COMPUTED

SUM

LINE statement:

pointer controls

Data set: GROCERY
Formats: $SCTRFMT., $MGRFMT., and $DEPTFMT.

The report in this example


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
            split='*';
 Note about code
   column sector manager department,sales perish;
 Note about code
   define sector / group format=$sctrfmt. 'Sector' '';
   define manager / group format=$mgrfmt. 'Manager* ';
 Note about code
   define department / across format=$deptfmt. '_Department_';
 Note about code
   define sales / analysis sum format=dollar11.2 ' ';
 Note about code
   define perish / computed format=dollar11.2
                'Perishable*Total';
 Note about code
   break after manager / skip;
 Note about code
   compute perish;
      perish=sum(_c3_, _c4_);
   endcomp;
 Note about code
   compute after;
      line @4 57*'-';
      line @4 '|   Combined sales for meat and dairy : '
           @46 _c3_ dollar11.2 '   |';
      line @4 '|   Combined sales for produce : '
           @46 _c4_ dollar11.2 '   |';
      line @4 '|' @60 '|';
      line @4 '|   Combined sales for all perishables: '
           @46 _c5_ dollar11.2 '   |';
      line @4 57*'-';
   endcomp;
 Note about code
   where sector contains 'n' 
         and (department='p1' or department='p2');
 Note about code
   title 'Sales Figures for Perishables in Northern Sectors';
run;

Output

       Sales Figures for Perishables in Northern Sectors       1

                       _______Department_______             
   Sector     Manager   Meat/Dairy      Produce   Perishable
                                                       Total
   ---------------------------------------------------------
                                                            
   Northeast  Alomar       $190.00       $86.00      $276.00
                                                            
              Andrews      $300.00      $125.00      $425.00
                                                            
   Northwest  Brown        $250.00       $73.00      $323.00
                                                            
              Pelfrey      $205.00       $76.00      $281.00
                                                            
              Reveiz       $600.00       $30.00      $630.00
                                                            
   ---------------------------------------------------------    
   |   Combined sales for meat and dairy :     $1,545.00   |    
   |   Combined sales for produce :              $390.00   |    
   |                                                       |    
   |   Combined sales for all perishables:     $1,935.00   |    
   ---------------------------------------------------------    

Previous Page | Next Page | Top of Page