Resources

Oil Wildcatter's Problem with an Insurance

 /****************************************************************/
 /*          S A S   S A M P L E   L I B R A R Y                 */
 /*                                                              */
 /*    NAME: DTREEE01                                            */
 /*   TITLE: Oil Wildcatter's Problem with an Insurance          */
 /*          (dtreee01)                                          */
 /* PRODUCT: OR                                                  */
 /*  SYSTEM: ALL                                                 */
 /*    KEYS: DTREE                                               */
 /*   PROCS: DTREE, PRINT                                        */
 /*    DATA:                                                     */
 /*                                                              */
 /* SUPPORT:                             UPDATE:                 */
 /*     REF: Example 1 from the DTREE chapter                    */
 /*    MISC:                                                     */
 /*                                                              */
 /****************************************************************/

/* -- create the STAGEIN= data set                  -- */
data Dtoils4;
format Stage $12. Stype $2. Outcome $14.
     Succ $12. Premium dollar12.0;
input Stage $12. Stype $4. Outcome $16. Succ $12.
    Premium dollar12.0;
datalines;
Drill       D   Drill           Insurance              .
.           .   Not_Drill       .                      .
Insurance   D   Buy_Insurance   Cost           -$130,000
.           .   Do_Not_Buy      Cost                   .
Cost        C   Low             Oil_Deposit            .
.           .   Fair            Oil_Deposit            .
.           .   High            Oil_Deposit            .
Oil_Deposit C   Dry             .                      .
.           .   Wet             .                      .
.           .   Soaking         .                      .
;

/* -- create the PROBIN= data set                   -- */
data Dtoilp4;
input (V1-V3) ($) P1-P3 ;
datalines;
Low         Fair        High        0.2     0.6     0.2
Dry         Wet         Soaking     0.5     0.3     0.2
;

/* -- create PAYOFFS= data set                      -- */
data Dtoilu4;
input (Cost Deposit Drill Insuran) ($16.) ;
format Drill $9. Insuran $14. Payoff dollar12.0;

/* determine the cost for this scenario */
if      Cost='Low'  then Rcost=150000;
else if Cost='Fair' then Rcost=300000;
else                     Rcost=500000;

/* determine the oil deposit and the corresponding  */
/* net payoff for this scenario                     */
if      Deposit='Dry' then Return=0;
else if Deposit='Wet' then Return=700000;
else                       Return=1200000;

 /* calculate the net return for this scenario */
if      Drill='Not_Drill' then Payoff=0;
else                           Payoff=Return-Rcost;

/* determine redeem received for this scenario */
if Insuran='Buy_Insurance' and Deposit='Dry' then
 Payoff=Payoff+200000;

/* drop unneeded variables */
drop Rcost Return;

datalines;
Low             Dry             Not_Drill       .
Low             Dry             Drill           Buy_Insurance
Low             Dry             Drill           Do_Not_Buy
Low             Wet             Not_Drill       .
Low             Wet             Drill           Buy_Insurance
Low             Wet             Drill           Do_Not_Buy
Low             Soaking         Not_Drill       .
Low             Soaking         Drill           Buy_Insurance
Low             Soaking         Drill           Do_Not_Buy
Fair            Dry             Not_Drill       .
Fair            Dry             Drill           Buy_Insurance
Fair            Dry             Drill           Do_Not_Buy
Fair            Wet             Not_Drill       .
Fair            Wet             Drill           Buy_Insurance
Fair            Wet             Drill           Do_Not_Buy
Fair            Soaking         Not_Drill       .
Fair            Soaking         Drill           Buy_Insurance
Fair            Soaking         Drill           Do_Not_Buy
High            Dry             Not_Drill       .
High            Dry             Drill           Buy_Insurance
High            Dry             Drill           Do_Not_Buy
High            Wet             Not_Drill       .
High            Wet             Drill           Buy_Insurance
High            Wet             Drill           Do_Not_Buy
High            Soaking         Not_Drill       .
High            Soaking         Drill           Buy_Insurance
High            Soaking         Drill           Do_Not_Buy
;

   /* -- print the payoff table          -- */
title "Oil Wildcatter's Problem";
title3 "The Payoffs";

proc print data=Dtoilu4;
run;

   /* -- PROC DTREE statements                       -- */
title "Oil Wildcatter's Problem";

proc dtree stagein=Dtoils4
           probin=Dtoilp4
           payoffs=Dtoilu4
           nowarning
           ;

  variables / stage=Stage type=Stype outcome=(Outcome)
              reward=(Premium) successor=(Succ)
              event=(V1 V2 V3) prob=(P1 P2 P3)
              state=(Cost Deposit Drill Insuran)
              payoff=(Payoff);

   evaluate;
   summary / target=Insurance;

   reset criterion=maxce rt=1200000;
   summary / target=Insurance;

   quit;
   /* -- clear up                                         -- */
  title ;