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


   /* Output 1 */

data idb;
   input @1 scp $4. @5 product $5. @11 company $21.
         @33 repname $8. @42 ref4 $5. @48 site $3.
         @52 invamt 8.;
   cards;
MVS QV1X  Quality Motor Company John Doe 09990 001 10000
MVS TEST  Quality Motor Company John Doe 09990 001 9500
MVS A9Z   Quality Motor Company John Doe 09990 001 2300
MVS TXT   Quality Motor Company John Doe 09990 001 12000
;

proc sort data=idb;
   by site;

   /* report of money spent on software                    */
options nonumber nodate linesize=64;
data _null_;
   file '
         /* external file */
                            ' print;
   set idb;
   by site;
      if first.site then do;
         total=0;
         put _page_;
         put 'Company:   ' @20 company /
             'REF4: '      @20 ref4    /
             'Site: '      @20 site    /
             'System: '    @20 scp;
         if repname=' ' then
            put  'Contact:  ' @20 repname;
      end;
   total+invamt;

   put / 'Product: 'product @20 'Invoiced Amount: '
                            @40 invamt;
   if last.site then put /  @20 'Total:  ' @40 total;
   format total invamt dollar12.;
run;


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


   /* Output 2 */

options linesize=123 ps=36 nodate nonumber;
title 'XYZ Real Estate Summary Report';

proc printto print='
                    /* external file */
                                       ' new;
run;

proc report data=housing nowd headskip headline;
   where bedr>=2 and bedr<=3;
   col type bedr n
       ('Purchase Price' '_Statistics_'
       price=prmean price=prmin price=prmax);
   define type / group width=8 'Type of/House';
   define bedr / group format=2. width=7 center 'Bedroom';
   define n / width=6 'Number/of' format=2. center;
   define prmean / mean format=dollar12.2 center
      'MEAN/Price';
   define prmin / min format=dollar12.2  center 'MIN/Price';
   define prmax / max format=dollar12.2  center 'MAX/Price';

   break after type / ol skip suppress summarize;
run;

proc printto;
run;


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


   /* Output 3 */

data sales;
   input name $ qtr $ numsold amtsold;
   cards;
Adams 1 3 60000
Adams 2 2 50000
Adams 3 1 22000
Adams 4 4 60000
Johnson 1 2 30000
Johnson 2 1 50000
Johnson 3 3 70000
Johnson 4 2 20000
;

options nonumber nodate ls=64;
title 'Quality Motor Company';

proc printto print='
                    /* external file */
                                       ' new;
run;

proc print data=sales label split='/';
   id name;
   sum amtsold;
   format amtsold dollar15.2;
   label name='Sales/Representative'
         qtr='Quarter'
         numsold='Cars Sold/by Quarter'
         amtsold='Total Sales/by Quarter';
run;

proc printto;
run;


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


   /* Output 4 */

options nonumber nodate ls=64;
title 'Quality Motor Company';

proc printto print='
                    /* external file */
                                       ' new;
run;

proc print data=sales label split='/';
   id name;
   by name;
   sum numsold amtsold;
   format amtsold dollar15.2;
   label name='Sales/Representative'
         qtr='Quarter'
         numsold='Cars Sold/by Quarter'
         amtsold='Total Sales/by Quarter';
run;

proc printto;
run; 


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


   /* Output 5 */

data sales;
input name $ qtr $ numsold amtsold;
cards;
Adams 1 3 60000
Adams 2 2 50000
Adams 3 1 22000
Adams 4 4 60000
Johnson 1 2 30000
Johnson 2 1 50000
Johnson 3 3 70000
Johnson 4 2 20000
;

options nonumber nodate ls=123 ps=30;
title 'Quality Motor Company';

proc printto print='
                    /* external file */
                                       ' new;
run;

proc report data=sales nowd headskip headline;
   col name qtr numsold amtsold avg;
   define name / group 'Sales/Representative' width=18;
   define qtr / group 'Quarter' center;
   define numsold / sum 'Cars Sold/by/Quarter'
                    center format=2. width=9;
   define amtsold / sum 'Total Sales/by/Quarter'
                    center format=dollar11.2;
   define avg / computed 'Average/Sales'
                center width=15 format=dollar10.2;
   compute after name;
      line @28 69*'=';
      line @28 'Sales totals for ' name  $7.
           +8 numsold.sum 3.
           +4 amtsold.sum dollar13.2
           +1 avg dollar13.2;
      line ' ';
      line ' ';
   endcomp;

   compute avg;
      avg=amtsold.sum/numsold.sum;
   endcomp;
run;

proc printto;
run;


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


   /* Output 6 */

libname mylib '
               /* SAS-data-library */
                                     ';
data mylib.employee;
   input idnum :$4. name & $12. emptype :$1.;
   cards;
341      Mann, Mary        H
511      Vega, Julie       S
5112     Delgado, Ed       S
5132     Overby, Phil      S
5151     Coxe, Susan       S
3551     Cobb, Joy F       H
3782     Bond, Jim S       S
381      Smith, Anna       S
;

data mylib.daily;
   input idnum $4. itemno quantity;
   cards;
341       101      2
341       103      1
511       101      1
511       103      1
5112      105      1
5112      101      3
5132      105      1
3551      104      1
3551      105      2
3782      104      1
3782      105      3
   more data lines
;

data mylib.prices;
   input itemno price;
   cards;
101      0.30
102      0.65
103      2.75
104      1.25
105      0.85
;

proc printto print='
                    /* external file */
                                       ' new;
run;

options nodate nonumber linesize=64;
title 'Restaurant Charge Summary';

proc sql;
   select e.idnum label='Employee ID',
          name label='Employee Name',
          sum(quantity*price) label='Total Charge'
          format=dollar5.2,
          case emptype
             when 'H' then 'cash charge'
             when 'S' then 'payroll deduct'
             else 'special'
          end label='Type of Charge'
      from mylib.employee as e, mylib.daily as d,
           mylib.prices as p
      where p.itemno=d.itemno and e.idnum=d.idnum
      group by e.idnum, name, 4;
quit;

proc printto;
run;


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


   /* Output 7 */

   /* This PROC SUMMARY step allows for the inclusion      */
   /* of summaries for separate classification varibles    */
   /* in the same data set.                                */
options nonumber nodate ls=64 ps=25;
title 'Quality Motor Company';
footnote1 'Displayed per Quarter';
footnote2 'and per Sales Rep';

proc summary data=sales;
   class name qtr;
   var numsold;
   output out=sales2 sum=;
run;

   /* The data set that was created with PROC SUMMARY      */
   /* contains summmarizations for the overall data set,   */
   /* the NAME variable, the QTR variable and the          */
   /* interactions of NAME/QTR values. The WHERE           */
   /* statement subsets the data so that only the          */
   /* summaries for NAME and QTR appear.                   */
proc printto print='
                    /* external file */
                                       ' new;
run;

proc print data=sales2 noobs split='/';
   label name    ='Sales/Representative'
         qtr     ='Quarter'
         numsold ='Number of/Sales';
    var name qtr numsold;
    where  _type_ in (1,2);
run;

proc printto;
run;


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


   /* Output 8 */

options nonumber nodate;
title 'XYZ Real Estate Detail Report';

proc printto print='
                    /* external file */
                                       ' new;
run;

proc report data=housing ls=123 ps=40 nowd
            split="/" headline headskip center ;
   where (price > 100000 and price < 250000);
   column  zone type bedr bath sqfeet age schools address
           price;
   define  zone / order format=$1. width=4 "Zone";
   define  type / order format=$8."Type";
   define  bedr / order format=2. width=7 center "Bedroom";
   define  bath / display format=2. width=4 center "Bath"; 
   define  sqfeet / display format=8. width=6  "Sqfeet";
   define  age / order format=3. "Age" ;
   define  schools / display format=$15. width=15 "School";
   define  address / display format=$25. width=25 "Address";
   define  price / mean format=dollar15.2 width=15 "Price";
   break after zone / ul skip suppress ;

run;

proc printto;
run;


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


   /* Output 9 */

options nodate nonumber;
title 'XYZ Real Estate Summary Report';

proc printto print='
                    /* external file */
                                       ' new;
run;

proc report data=housing ls=123 ps=50 nowd
             split="/" headline headskip center ;
   column  zone bedr N price=pmean price=pmin price=pmax;
   define  zone / group format= $4. "Zone";
   define  N / 'Number/of' width=6 center format=2.;
   define  bedr / group format=2. width=7 center "Bedroom";
   define  pmean / mean format=dollar11.2 "Mean/Price";
   define  pmin  / min  format=dollar11.2 "Min/Price";
   define  pmax  / max  format=dollar11.2 "Max/Price";
   break after zone / skip;
run;

proc printto;
run;


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


   /* Output 10 */

proc format;
   value sex 1='Female'  2='Male';
   value occupat 1='Technical'  2='Manager/Supervisor'
                 3='Clerical'   4='Administrative';
   value regfmt 1='North' 2='South'
                3='East' 4='West';
run;

options linesize=123 ps=35 nodate nonumber;
title 'Job Category Data';

proc printto print='
                    /* external file */
                                       ' new;
run;

proc tabulate data=demo format=6.;
   label occupat='Job Class';
   keylabel all='TOTAL';
   class sex region occupat;
   format sex sex. occupat occupat. region regfmt.;
   table occupat all,region*sex*
         (n*f=2.0 pctn*f=6.2) /
         rts=20;
run;

proc printto;
run;


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


   /* Output 11 */

proc format;
   value sex 1='_Female_'  2='_Male_';
   value occupat 1='Technical'  2='Manager/Supervisor'
                 3='Clerical'   4='Administrative';
   value regfmt 1='North' 2='South'
                3='East' 4='West';
run;

options linesize=150 nodate nonumber;
title 'Job Category Data';

proc printto print='
                    /* external file */
                                       ' new;
run;

proc report data=demo nowd;
   column  occupat region,sex,(n pctn);

   define  occupat / group format=occupat. width=18
           order=internal
                      'Job Class';
   define  region / across width=15  order=internal
           format=regfmt.;
   define  sex / across format= sex. width=9
           order=internal ' ';
   define  n / "N" format=2.0 width=5;
   define  pctn / computed format=3.0 width=5;

   rbreak before /;
   rbreak after / dol summarize ;

   compute before ;
   denom1=_c2_;
   denom2=_c4_;
   denom3=_c6_;
   denom4=_c8_;
   denom5=_c10_;
   denom6=_c12_;
   denom7=_c14_;
   denom8=_c16_;
   endcomp;

   compute  pctn;
   _c3_=(_c2_/denom1)*100;
   _c5_=(_c4_/denom2)*100;
   _c7_=(_c6_/denom3)*100;
   _c9_=(_c8_/denom4)*100;
   _c11_=(_c10_/denom5)*100;
   _c13_=(_c12_/denom6)*100;
   _c15_=(_c14_/denom7)*100;
   _c17_=(_c16_/denom8)*100;
   endcomp;
run;

proc printto;
run;


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


   /* Output 12 */

options linesize=64 pagesize=28 nodate pageno=1;

proc printto print='
                    /* external file */
                                       ' new;
run;

proc loan;
   fixed amount=95000 life=180 rate=7.5 downpayment=20000
         points=2 label='7.5% Fixed Rate Loan, 15 Years'
         start=1993:9 schedule;
run;

proc printto;
run;


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


   /* Output 13 */

options linesize=64 pagesize=28 nodate pageno=1;

proc printto print='
                    /* external file */
                                       ' new;
run;

proc loan;

      /* specify the first loan                            */
   fixed
      amount=95000 life=180 rate=7.5 downpayment=20000
      points=2
      label='7.5% Fixed Rate Loan, 15 Years'
      start=1993:9;

      /* specify the second loan                           */
   arm
      amount=95000 life=180 rate=6.0 downpayment=20000
      points=2 caps=(2, 6) adjustfreq=12 worstcase
      label='6.0% ARM Loan, 15 Years, Worst Case'
      start=1993:9;

      /* compare the loans at the end of years 1, 5, 10    */
   compare at=(12 60 120);
run;

proc printto;
run;


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


data prices;
   input     partnmbr $9.
         @11 quantity 3.
         @15 price 6.2;
   cards;
B01-03/06 100  5.75
B02-03/08 100  6.60
B03-03/10  79  7.25
B04-03/12  37  7.80

   /* more data lines */

;
options linesize=123 ps=38 nodate nonumber;
title 'Quality Motors Parts Inventory';

proc printto print='
                    /* external file */
                                       ' new;
run;

proc report data=prices panels=2 headskip nowd pspace=15;
   col partnmbr quantity price;
   define partnmbr / display 'Part Number';
   define quantity / center format=3. width=7 'On Hand';
   define price / display format=dollar6.2 'Price';
run;

proc printto;
run;


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


data prices;
   input partnmbr $10.
        @11 quantity 3.
        @15 price 6.2;
   cards;
B01-03/06 100  5.75
B02-03/08 100  6.60
B03-03/10  79  7.25
B04-03/12  37  7.80

   /* more data lines */
;

options linesize=123 pagesize=45 nodate nonumber;
title 'Quality Motors Parts Inventory';

data _null_;
   file '
         /* external file */
                            ' n=pagesize;
   do column=20, 71;
      put #3 @column 'Part';
      put #4 @column 'Number' +7 'On Hand' +3 'Price';
      do line=5 to 38;
      set prices end=endfile;
      put #line @column partnmbr
                +5 quantity 3.
                +4 price dollar6.2;
      end;
   end;
if endfile=0 then put _page_;
run;


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


   /*------------------------------------------------------*
    | Summary                                              |
    |   This program creates a multilevel tabular report   |
    |   using the data set WORK.HOUSES and displaying up   |
    |   to five across and down levels.                    |
    | Generated: 120CT93 11:04:28                          |
    *------------------------------------------------------*     
    | The OPTIONS statement specifies the dimensions of    |
    | the printed output in characters per line and lines  |
    | per page and whether or not the current date and     |
    | page number are printed.                             |
    | The TITLE and FOOTNOTE statements clear any          |
    | previously defined titles or footnotes.              |
    *------------------------------------------------------*/
options linesize=123 pagesize=35 date number pageno=1;
title;
footnote;
proc tabulate data=WORK.HOUSES
   ;
     where
   bedr>=2 and bedr<=3;
   class TYPE BEDR;
   var PRICE;
   table (TYPE) * (BEDR),
      (PRICE) * ('N' 'MEAN' 'MIN' 'MAX')
      ;
   keylabel N=' ' SUM=' ';
run;


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


   /*------------------------------------------------------*
    | Summary                                              |
    |   This program creates a multilevel tabular report   |
    |   using the data set WORK.HOUSES and displaying up   |
    |   to five across and down levels.                    |
    | Generated: 120CT93 11:04:28                          |
    *------------------------------------------------------*     
    | The OPTIONS statement specifies the dimensions of    |
    | the printed output in characters per line and lines  |
    | per page and whether or not the current date and     |
    | page number are printed.                             |
    | The TITLE and FOOTNOTE statements clear any          |
    | previously defined titles or footnotes.              |
    *------------------------------------------------------*/
options linesize=123 pagesize=40 nodate number pageno=1;
title 'Current Listings by Zone';
footnote;
proc tabulate data=WORK.HOUSES
   ;
      where
   bedr>=2 and bedr<=3;
   class zone TYPE BEDR;
   var PRICE;
   table (zone) * (TYPE) * (BEDR),
      (PRICE) * ('N' 'MEAN' 'MIN' 'MAX')
      ;
   keylabel N=' ' SUM=' ';
run;


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


proc sql;
   select distinct ASALESMN.ID label='ID', AEMPLYEE.FNAME
          label='FNAME', AEMPLYEE.LNAME
          label='LNAME', AEMPLYEE.STATE
          label='STATE',
          (select SUM(ASALE.AMOUNT)
             from PERMDATA.ASALE as _SE_2
          where ((ASALE.SALESMAN=_SE_1.ID)
                and (YEAR(ASALE.DATE)=1990) and exists
                (select *
                   from PERMDATA.AITEM
                where (AITEM.TYPE
                      in ('Apollo', 'HP 9000',
                      'IBM 3090',
                      'IBM 4381', 'PC', 'VAX 8700')
                      and (AITEM.NUMBER=_SE_2.ITEM))
                ))
          ) label='SUM of AMOUNT' format=DOLLAR26.2
      from PERMDATA.ASALESMN as _SE_1, PERMDATA.AEMPLYEE
      where ((AEMPLYEE.ID=ASALESMN.ID)
            and ((AEMPLYEE.STATE='Florida')
            or (AEMPLYEE.STATE='Iowa')))
   order by ASALESMN.ID;
quit;


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