Previous Page | Next Page

The REPORT Procedure

Example 13: Storing Computed Variables as Part of a Data Set


Procedure features:

PROC REPORT statement options:

OUT=

COMPUTE statement:

with a computed variable as report-item

DEFINE statement options:

COMPUTED

Other features: CHART procedure
Data set: GROCERY
Formats: $SCTRFMT.

The report in this example


Program That Creates the Output Data Set

 Note about code
libname proclib 'SAS-library';
 Note about code
options nodate pageno=1 linesize=64 pagesize=60
        fmtsearch=(proclib);
 Note about code
title;
 Note about code
proc report data=grocery nowd out=profit;
 Note about code
   column sector manager department sales Profit;
 Note about code
   define profit / computed;
 Note about code
      /* Compute values for Profit. */
   compute profit;
      if department='np1' or department='np2' then profit=0.4*sales.sum;
      else profit=0.25*sales.sum;
   endcomp;
run;


The Output Data Set

 Note about figure
                      The Data Set PROFIT                      1

 Sector    Manager   Department      Sales     Profit  _BREAK__
 se        1         np1                50         20          
 se        1         p1                100         25          
 se        1         np2               120         48          
 se        1         p2                 80         20          
 se        2         np1                40         16          
 se        2         p1                300         75          
 se        2         np2               220         88          
 se        2         p2                 70       17.5          
 nw        3         np1                60         24          
 nw        3         p1                600        150          
 nw        3         np2               420        168          
 nw        3         p2                 30        7.5          
 nw        4         np1                45         18          
 nw        4         p1                250       62.5          
 nw        4         np2               230         92          
 nw        4         p2                 73      18.25          
 nw        9         np1                45         18          
 nw        9         p1                205      51.25          
 nw        9         np2               420        168          
 nw        9         p2                 76         19          
 sw        5         np1                53       21.2          
 sw        5         p1                130       32.5          
 sw        5         np2               120         48          
 sw        5         p2                 50       12.5          
 sw        6         np1                40         16          
 sw        6         p1                350       87.5          
 sw        6         np2               225         90          
 sw        6         p2                 80         20          
 ne        7         np1                90         36          
 ne        7         p1                190       47.5          
 ne        7         np2               420        168          
 ne        7         p2                 86       21.5          
 ne        8         np1               200         80          
 ne        8         p1                300         75          
 ne        8         np2               420        168          
 ne        8         p2                125      31.25          

Program That Uses the Output Data Set

 Note about code
options nodate pageno=1 linesize=80 pagesize=60
        fmtsearch=(proclib);
 Note about code
proc chart data=profit;
   block sector / sumvar=profit;
   format sector $sctrfmt.;
   format profit dollar7.2;
   title 'Sum of Profit by Sector';
run;

Output from Processing the Output Data Set

                            Sum of Profit by Sector                            1

                            Sum of Profit by Sector

                                ___
                               /_ /|
                  ___         |**| |
                 /_ /|        |**| |
                |**| |        |**| |
                |**| |        |**| |
                |**| |        |**| |          ___           ___
               -|**| |--------|**| |---------/_ /|---------/_ /|-------
              / |**| |      / |**| |      / |**| |      / |**| |      /
             /  |**| |     /  |**| |     /  |**| |     /  |**| |     /
            /   |**| |    /   |**| |    /   |**| |    /   |**| |    /
           /    |**|/    /    |**|/    /    |**|/    /    |**|/    /
          /             /             /             /             /
         /     $627.25 /     $796.50 /     $309.50 /     $327.70 /
        /-------------/-------------/-------------/-------------/

          Northeast     Northwest     Southeast     Southwest

                                Sector

Previous Page | Next Page | Top of Page