Resources

Cost Analysis (intpm8)

/****************************************************************/
/*          S A S   S A M P L E   L I B R A R Y                 */
/*                                                              */
/*    NAME: INTPM8                                              */
/*   TITLE: Cost Analysis (intpm8)                              */
/* PRODUCT: OR                                                  */
/*  SYSTEM: ALL                                                 */
/*    KEYS:                                                     */
/*   PROCS: CPM, PRINT                                          */
/*    DATA:                                                     */
/*                                                              */
/* SUPPORT:                             UPDATE:                 */
/*     REF: Example 8 from the chapter, Introduction to Project */
/*          Management.                                         */
/*    MISC:                                                     */
/*                                                              */
/****************************************************************/

data survcost;
   format id $20. activity $8. succ1-succ3 $8. ;
   input id & activity & duration succ1 & succ2 & succ3 & cost;
   datalines;
Plan Survey           plan sur   4 hire per  design q  .        300
Hire Personnel        hire per   5 trn per   .         .        350
Design Questionnaire  design q   3 trn per   select h  print q  100
Train Personnel       trn per    3 cond sur  .         .        500
Select Households     select h   3 cond sur  .         .        300
Print Questionnaire   print q    4 cond sur  .         .        250
Conduct Survey        cond sur  10 analyze   .         .        200
Analyze Results       analyze    6 .         .         .        500
;

data holidata;
   format hol date7.;
   hol = '4jul03'd;
   run;

data costavl;
   input per & date7. otype $ cost;
   format per date7.;
   datalines;
.       restype   2
1jul03  reslevel  12000
;


proc cpm date='1jul03'd interval=weekday
         data=survcost resin=costavl   holidata=holidata
         out=sched     resout=survrout;
   activity   activity;
   successor  succ1-succ3;
   duration   duration;
   holiday    hol;
   id         id;
   resource   cost / period  = per
                     obstype = otype cumusage;
   run;

data basecost (keep = _time_ bcws);
   set survrout;
   bcws = ecost;
   run;


data actual;
   format id $20. ;
   input id & as & date9. af & date9. actcost;
   format as af date7.;
   datalines;
Plan Survey            1JUL03   8JUL03   275
Hire Personnel         9JUL03  15JUL03   350
Design Questionnaire  10JUL03  14JUL03   150
Train Personnel       16JUL03  17JUL03   800
Select Households     15JUL03  17JUL03   450
Print Questionnaire   15JUL03  18JUL03   250
Conduct Survey        21JUL03   .        200
;

data work.update;
   merge survcost actual;
   run;

data costavl2;
   input per & date7. otype $ cost actcost;
   format per date7.;
   datalines;
.       restype   2      2
1jul03  reslevel  12000  12000
;


title 'Activity Data Set UPDATE';
proc print data=work.update;
   run;

title 'Resource Data Set COSTAVL2';
proc print data=costavl2;
   run;

proc cpm date='1jul03'd interval=weekday
         data=work.update    resin=costavl2
         out=updsched   resout=updtrout
         holidata=holidata;
   activity   activity;
   successor  succ1-succ3;
   duration   duration;
   holiday    hol;
   id         id;
   resource   cost actcost / per     = per
                             obstype = otype
                             maxdate = '21jul03'd cumusage;
   actual / a_start=as a_finish=af;
   run;

title 'Updated Schedule: Data Set UPDSCHED';
proc print data=updsched;
   run;

data updtcost (keep = _time_ bcwp acwp);
   set updtrout;
   bcwp = ecost;
   acwp = eactcost;
   run;

/* Create a combined data set to contain the BCWS, BCWP, ACWP */
/* per day and the cumulative values for these costs.         */
data costs;
   merge basecost updtcost;
   run;


title 'BCWS, BCWP, and ACWP';
proc print data=costs;
   run;

   /* Plot the cumulative costs */
   data costplot (keep=date dollars id);
      set costs;
      format date date7.;
      date = _time_;
      if bcws ^= . then do;
         dollars = BCWS; id = 1; output;
         end;
      if bcwp ^= . then do;
         dollars = BCWP; id = 2; output;
         end;
      if acwp ^= . then do;
         dollars = ACWP; id = 3; output;
         end;
      run;


legend1 frame
        value=(c=black j=l 'BCWS' 'BCWP' 'ACWP')
        label=(c=black);

axis1 width=2
      order=('1jul03'd to '1aug03'd by week)
      length=60 pct
      value=(c=black)
      label=(c=black);

axis2 width=2
      order=(0 to 12000 by 2000)
      length = 55 pct
      value=(c=black)
      label=(c=black);

symbol1 i=join v=none c=green  w=4 l=1;
symbol2 i=join v=none c=blue   w=4 l=2;
symbol3 i=join v=none c=red    w=4 l=3;
title c=black h=2.5 'Comparison of Costs';

proc gplot data=costplot;
   plot dollars * date = id / legend=legend1
                              haxis=axis1
                              vaxis=axis2;
   run;