Loan Grant Decision Problem (dtreee05)

 /**************************************************************/
 /*          S A S   S A M P L E   L I B R A R Y               */
 /*                                                            */
 /*    NAME: DTREEE05                                          */
 /*   TITLE: Loan Grant Decision Problem (dtreee05)            */
 /* PRODUCT: OR                                                */
 /*  SYSTEM: ALL                                               */
 /*    KEYS: OR                                                */
 /*   PROCS: DTREE PRINT                                       */
 /*    DATA:                                                   */
 /*                                                            */
 /* SUPPORT:                             UPDATE:               */
 /*     REF: Example 5 from the DTREE chapter                  */
 /*    MISC:                                                   */
 /*                                                            */
 /**************************************************************/

/* -- create the STAGEIN= data set                  -- */
data Stage6;
format _STNAME_ $14. _STTYPE_ $2. _OUTCOM_ $20. _SUCC_ $14. ;
input _STNAME_ $ _STTYPE_ $ _OUTCOM_ & _SUCC_ $ ;
datalines;
Application     D   Approve loan            Payment
.               .   Deny loan               .
Payment         C   Pay off                 .
.               .   Default                 .
Investigation   D   Order investigation     Recommendation
.               .   Do not order            Application
Recommendation  C   Positive                Application
.               .   Negative                Application
;

/* -- create the PROBIN= data set                   -- */
data Prob6;
length _GIVEN_ _EVENT1_ _EVENT2_ $16;

_EVENT1_='Pay off';   _EVENT2_='Default';
_PROB1_=664/700;      _PROB2_=1.0-_PROB1_;
output;

_GIVEN_='Pay off';
_EVENT1_='Positive';   _EVENT2_='Negative';
_PROB1_=570/664;       _PROB2_=1.0-_PROB1_;
output;

_GIVEN_='Default';
_EVENT1_='Positive';   _EVENT2_='Negative';
_PROB1_=6/26;          _PROB2_=1.0-_PROB1_;
output;

run;

/* -- create the PAYOFFS= data set                  -- */
data Payoff6(drop=loan);
length _STATE_ _ACT_ $24;

loan=30000;

_ACT_='Deny loan';   _VALUE_=loan*0.08;   output;
_STATE_='Pay off';   _VALUE_=loan*0.08;   output;
_STATE_='Default';   _VALUE_=loan*0.08;   output;

_ACT_='Approve loan';
_STATE_='Pay off';   _VALUE_=loan*0.15;   output;
_STATE_='Default';   _VALUE_=-1.0*loan;   output;

run;

   /* -- define title                                  -- */
title 'Loan Grant Decision';

   /* -- PROC DTREE statements                         -- */
proc dtree
     stagein=Stage6 probin=Prob6 payoffs=Payoff6
     summary target=investigation nowarning;

   modify 'Order investigation' reward -500;

   evaluate;

   OPTIONS LINESIZE=85;
   summary / target=Application;
   OPTIONS LINESIZE=80;

     save;
     move payment before investigation;
     evaluate;
     recall;
     vpi payment;
     save;
     modify payment type;
     evaluate;
     recall;
     vpc payment;

  quit;

   /* -- create the alternative PAYOFFS= data set  -- */
 data Payoff6a(drop=loan);
   length _STATE_ _ACT_ $24;
   loan=1;

   _ACT_='Deny loan';   _VALUE_=loan*0.08;   output;
   _STATE_='Pay off';   _VALUE_=loan*0.08;   output;
   _STATE_='Default';   _VALUE_=loan*0.08;   output;

   _ACT_='Approve loan';
   _STATE_='Pay off';   _VALUE_=loan*0.15;   output;
   _STATE_='Default';   _VALUE_=-1.0*loan;   output;
run;

   /* -- PROC DTREE statements                     -- */
title 'Loan Grant Decision';

proc dtree
     stagein=Stage6 probin=Prob6 payoffs=Payoff6a
     nowarning;

   evaluate / summary target=investigation;

   save;
   move payment before investigation;
   evaluate;

   recall;
   modify payment type;
   evaluate;

quit;


   /* create the data set for value of loan   */
   /* and corresponding values of services    */
data Datav6(drop=k ratio1 ratio2 ratio3);
   label loan="Value of Loan"
         vci="Value of Current Credit Investigation"
         vpi="Value of Perfect Credit Investigation"
         vpc="Value of Perfect Collecting Service";

      /* calculate ratios */
   ratio1=0.1242-0.0909;
   ratio2=0.1464-0.0909;
   ratio3=0.15-0.0909;

   Loan=0;
   do k=1 to 10;

         /* set the value of loan */
      loan=loan+10000;

         /* calculate the values of various services */
      vci=loan*ratio1;
      vpi=loan*ratio2;
      vpc=loan*ratio3;

         /* output current observation */
      output;
   end;
run;

   /* print the table of the value of loan   */
   /* and corresponding values of services   */
title 'Value of Services by Value of Loan';

proc print label;
   format loan vci vpi vpc dollar12.0;
run;