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


proc access dbms=db2 accdesc=sasdata.frqflyr;
   create sasdata.ny93.view;
   select ffid mbrtype name miletrav;
   subset where state='NY' and miletrav>90000;
run;


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


proc tabulate data=sasdata.ny93;
   var miletrav;
   class mbrtype;
   tables mbrtype, miletrav*mean;
   title 'Average Miles for Membership Categories';
run;


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


proc fsedit data=sasdata.ny93;
run;


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


proc sql;
   create view sasdata.pilotv as
      select idnum, jobcode, gender, salary,
             salary*.08 as bonus
      from sasdata.personl
      where jobcode contains 'PILOT'
            and salary < 70000
      order by salary;


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


proc gchart data=sasdata.pilotv;
   vbar jobcode/sumvar=salary ctext=cyan
        patternid=midpoint;
   title 'Bonus and Salary Information';
run;


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


proc sql;
   describe view sasdata.pilotv;


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


proc sql;
   create view sasdata.mpilot as
      select idnum, salary, bonus
      from sasdata.pilotv
      where gender='M';


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


proc sql;
   create view sasdata.company as
      select company, city, state, orders.product,
             quantity, unitcost*quantity as cost
      from sasdata.prices, sasdata.orders, 
           sasdata.customer
      where prices.product=orders.product and
            orders.custid=customer.custid
      order by orders.custid, orders.product;
run;


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


data sasdata.current;
   infile mydata;
   input @20 trandate mmddyy8. @;
   if trandate=today();
   input @1 invoice $char4. supplier $char15.
      @28 itemno $char4. amount comma8. clerk $char6.
      location $2. state $2. billcode $3. priority $1.
      quantity comma6. payflag $1.;
   if billcode='120' then due=trandate+45;
      else due=trandate+30
   format trandate due date7.; 
run;


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


data sasdata.current/view=sasdata.current; 
   infile mydata;
   input @20 trandate mmddyy8. @;
   if trandate=today();
   input @1 invoice $char4. supplier $char15.
     @28 itemno $char4. amount comma8. clerk $char6.
     location $2. state $2. billcode $3. priority $1.
     quantity comma6. payflag $1.;
   if billcode='120' then due=trandate+45;
      else due=trandate+30;
   format trandate due date7.;
run;


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


proc print data=sasdata.current;
   title "Transactions for &sysdate";
run;


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


data sasdata.year;
   set sasdata.qtr1 sasdata.qtr2 sasdata.qtr3
       sasdata.qtr4;
   by account;
run;


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


data sasdata.year/view=sasdata.year;
   set sasdata.qtr1 sasdata.qtr2 sasdata.qtr3
       sasdata.qtr4;
   by account;
run;


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


proc means data=sasdata.year mean min max;
   title 'Descriptive Statistics';
run;


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