/********************************************************/
   /* INVOICE.SAS is a program that creates an             */
   /* informational invoice for each customer of the       */
   /* Olympic Games. This may include such                 */
   /* information as air transporation, lodging and        */
   /* ticketing.                                           */
   /********************************************************/

libname saslib 'Novell:SAS data';
filename cfrm 
   'Novell:reports:confirmation.txt';
options nonumber nodate;
title;
data _null_;
   set saslib.olympics;  
   by custnum;
   retain echarges 0;
   length templnam $10 tempfnam $10;
   file cfrm print ls=75 ps=60;
   if first.custnum then 
      do;
         echarges=0;
         if _n_ ^= 1 then put _page_;
         templnam = trim(lname);
         tempfnam = trim(fname);
         put tempfnam templnam  @55 "&SYSDATE"/ address /  
            city ', ' country / @5 zip //;
         put 'Dear ' tempfnam templnam  ',' /;
         put 'Below you will find complete information' 
            'about the upcoming Olympics.';
         put 'The information is broken down into the '
            'following categories:' /;
         put @10  'AIR TRANSPORTATION' / @10 'LODGING' / 
            @10 'EVENTS' /;
         put 'Please note that you have already paid in '
            'full and this is not a bill.';
         put 'The total charges listed below is simply '
            'for your records.' /;
         put 'Thank you for your contributions to the '
            '1996 Olympics in Atlanta, USA.';
         put // @10 "AIR TRANSPORTATION" overprint @10 
            "__________________";
         put 'WORLDWIDE AIRLINE   CITY OF      DEPARTURE'
            '         ARRIVAL';
         put '  FLIGHT #         DEPARTURE     DATE/TIME'
            '         DATE/TIME  '/;
         put @5 inflight   @20 city  @34 dep_home @52  
            arr_olym;
         put @5 ouflight @20 "Atlanta" @34 dep_olym @52 
            arr_home /;
         put 'NUMBER OF TICKETS= ' people @40 /
            'TOTAL COST OF AIR TRANSPORTATION= ' 
            airprice dollar10.2;
         put /// @10 "LODGING" overprint @10 "_______";
         put 'HOTEL= ' hotel '  NUMBER OF OCCUPANTS= ' 
            people 'SMOKING? '  smoke;
         put 'SPECIAL CONSIDERATIONS - ' comment /;
         put 'TOTAL COST OF LODGING= '  lodprice 
            dollar10.2;
         put /// @10 "OLYMPIC EVENTS" overprint @10 
            "_______________";
         put '                                          '
            '          TICKET       SESSION';
         put 'DATE       EVENT                CODE     '
            ' QUANTITY  PRICE        PRICE';
         put date  @12 event @33 code @47 qty @53 t_price 
            @66 s_price;
      end;
   else 
      do;
         put date @12 event @33 code @47 qty @53 t_price 
            @66 s_price;
      end;
   echarges+s_price;
   if last.custnum then 
      do;
         totch=airprice+lodprice + echarges;
         put /// ' ** TOTAL CHARGES FOR 1996 OLYMPICS **'
            '  ' totch dollar10.2;
      end;
run;