/**********************************************************************/


   /* Example 1:  Displaying Percentages */

options missing=' ';
proc report data=travel ls=100 ps=60 split='/' headline
                        headskip center nowindows;
   title 'Travel Expense Report';
   column rownum region name hotel air total perreg pertot;
   define rownum / computed format=2. width=3 'Row';
   define region / order center 'Region' width=6;
   define name   / order 'Sales/Representative' width=15;
   define hotel  / sum noprint;
   define air    / sum noprint;
   define total  / computed format=dollar9. 'Total';
   define perreg / computed format=percent9.2 width=10
                   'Regional/Percentage';
   define pertot / computed format=percent9.2 width=10
                   'Overall/Percentage';

compute rownum;
   count+1;
   rownum=count;
endcomp;

compute total;
  total=air.sum+hotel.sum;
endcomp;

compute perreg;
   perreg=total/rtot;
endcomp;

compute pertot;
   pertot=total/gtot;
endcomp;

break after region / skip;
compute before region;
   rtot=total;
   count+(-1);
endcomp;

compute after region;
   count+(-1);
   rownum=.;
   line @13 31*'-' @52 9*'-' @68 9*'-' @85 8*'-';
   line @18 'Summary for Region ' region $1. 
        @51 total dollar9.
        @68 perreg percent9.2 @84 pertot percent9.2;
endcomp;

compute before;
   gtot=total;
   count+(-1);
endcomp;


/**********************************************************************/


   /* Example 2:  Referencing Positions of Columns */
 
proc format;
   value $namefmt 'BECKER'='_Becker_'
                  'FOSTER'='_Foster_'
                  'GRANT' ='_Grant_'
                  'NORMAN'='_Norman_'
                  'THOMAS'='_Thomas_';
title1 'Example of Referencing Column Positions';
title2 'for an ACROSS Variable';
proc report ls=132 ps=54 split="/" headline center
            data=travel nowindows;
   column dest name,( n colper cumper);
   define dest / group width=11 'Destination';
   define name / across format= $namefmt. width=7
                 '_Sales Representative_' ;
   define n / width=5 format=2. center '# /Trips' ;
   define colper / computed format=percent6. width=7
                  'Column/Percent' ;
   define cumper / computed format=percent6. width=7
                  'Cumm./Percent' ;

compute before;
   c2tot=_c2_;
   c5tot=_c5_;
   c8tot=_c8_;
   c11tot=_c11_;
   c14tot=_c14_;
endcomp;

compute colper;
   _c3_=_c2_/c2tot;
   _c6_=_c5_/c5tot;
   _c9_=_c8_/c8tot;
   _c12_=_c11_/c11tot;
   _c15_=_c14_/c14tot;
endcomp;

compute before dest;
   cumcol3+_c3_;
   cumcol6+_c6_;
   cumcol9+_c9_;
   cumcol12+_c12_;
   cumcol15+_c15_;
endcomp;

compute cumper;
   _c4_=cumcol3;
   _c7_=cumcol6;
   _c10_=cumcol9;
   _c13_=cumcol12;
   _c16_=cumcol15;
endcomp;

rbreak after / ol ul summarize;

compute after;
   dest='totals';
endcomp;


/**********************************************************************/