| Procedure features: | 
| 
 PROC REPORT
statement options: 
 |  
| 
 COMPUTE statement: 
 | 
 with a computed variable as report-item  |    |  
| 
 DEFINE statement options: 
 |   
 | 
| Other features: | 
CHART procedure
 | 
| Data set: | 
GROCERY
 | 
| Formats: | 
$SCTRFMT.
 | 
The report in this example 
- 
creates a
computed variable
 
- 
stores it in an output data set
 
- 
uses that data set to create a chart based on the computed variable.
 
 
   | 
libname proclib 'SAS-library';  | 
   | 
options nodate pageno=1 linesize=64 pagesize=60
        fmtsearch=(proclib); | 
   | 
title;  | 
   | 
proc report data=grocery nowd out=profit;  | 
   | 
   column sector manager department sales Profit;  | 
   | 
   define profit / computed;  | 
   | 
      /* 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 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          
 
 |    | 
  
   | 
options nodate pageno=1 linesize=80 pagesize=60
        fmtsearch=(proclib); | 
   | 
proc chart data=profit;
   block sector / sumvar=profit;
   format sector $sctrfmt.;
   format profit dollar7.2;
   title 'Sum of Profit by Sector';
run;  | 
                            Sum of Profit by Sector                            1
                            Sum of Profit by Sector
                                ___
                               /_ /|
                  ___         |**| |
                 /_ /|        |**| |
                |**| |        |**| |
                |**| |        |**| |
                |**| |        |**| |          ___           ___
               -|**| |--------|**| |---------/_ /|---------/_ /|-------
              / |**| |      / |**| |      / |**| |      / |**| |      /
             /  |**| |     /  |**| |     /  |**| |     /  |**| |     /
            /   |**| |    /   |**| |    /   |**| |    /   |**| |    /
           /    |**|/    /    |**|/    /    |**|/    /    |**|/    /
          /             /             /             /             /
         /     $627.25 /     $796.50 /     $309.50 /     $327.70 /
        /-------------/-------------/-------------/-------------/
          Northeast     Northwest     Southeast     Southwest
                                Sector
 
Copyright © 2010 by SAS Institute Inc., Cary, NC, USA. All rights reserved.