Program Flow Example for PROC COMPUTAB

/*--------------------------------------------------------------

                    SAS Sample Library

        Name: ctasx01.sas
 Description: Example program from SAS/ETS User's Guide,
              The COMPUTAB Procedure
       Title: Program Flow Example for PROC COMPUTAB
     Product: SAS/ETS Software
        Keys: programmable tabular reports
        PROC: COMPUTAB
       Notes:

--------------------------------------------------------------*/


title 'Program Flow Example for PROC COMPUTAB';

data example;
   input year sales cgs;
datalines;
1988    83      52
1989   106      85
1990   120     114
;

proc computab data=example;

   columns c88 c89 c90 total;
   rows sales cgs gprofit pctmarg;

   /* calculate gross profit */
   gprofit = sales - cgs;

   /* select a column */
   c88 = year = 1988;
   c89 = year = 1989;
   c90 = year = 1990;

   /* calculate row totals for sales */
   /* and cost of goods sold */
   col: total = c88 + c89 + c90;

   /* calculate profit margin */
   row: pctmarg = gprofit / cgs * 100;
run;