Multiple Calendars (cpme10)

 /****************************************************************/
 /*          S A S   S A M P L E   L I B R A R Y                 */
 /*                                                              */
 /*    NAME: CPME10                                              */
 /*   TITLE: Multiple Calendars (cpme10)                         */
 /* PRODUCT: OR                                                  */
 /*  SYSTEM: ALL                                                 */
 /*    KEYS: CPM                                                 */
 /*   PROCS: CPM                                                 */
 /*    DATA:                                                     */
 /*                                                              */
 /* SUPPORT:                             UPDATE:                 */
 /*     REF: Example 10 from the CPM Chapter (PM User's Guide)   */
 /*    MISC:                                                     */
 /*                                                              */
 /****************************************************************/


 /* Activity-on-Node representation of the project */
data widget9;
   input task $ 1-12 days succ1 $ 19-30 succ2 $ 33-44 succ3 $ 47-58;
   datalines;
Approve Plan 5.5  Drawings      Study Market  Write Specs
Drawings      10  Prototype
Study Market   5  Mkt. Strat.
Write Specs  4.5  Prototype
Prototype     15  Materials     Facility
Mkt. Strat.   10  Test Market   Marketing
Materials     10  Init. Prod.
Facility      10  Init. Prod.
Init. Prod.   10  Test Market   Marketing     Evaluate
Evaluate      10  Changes
Test Market   15  Changes
Changes        5  Production
Production     0
Marketing      0
;

title 'Multiple Calendars';

data workdata;
   input fullday time8. halfday time8. ovtday time8.
         s1 time8. s2 time8. s3 time8.;
   format fullday halfday ovtday s1 s2 s3 time6.;
   datalines;
08:00   08:00   08:00   .       08:00   .
16:00   12:00   18:00   06:00   18:00   06:00
.       .       .       08:00   20:00   08:00
.       .       .       18:00   .       18:00
.       .       .       20:00   .       .
.       .       .       .       .       .
;

title 'Multiple Calendars';
proc print;
   title2 'Workdays Data Set';
   run;

data calendar;
   input  cal $ _sun_ $ _mon_$ _tue_$  _wed_$ _thu_$ _fri_$ _sat_ $;
   datalines;
DEFAULT  holiday fullday fullday fullday fullday fullday holiday
OVT_CAL  holiday ovtday  ovtday  ovtday  ovtday  ovtday  halfday
PROD_CAL holiday s2      s1      s1      s1      s1      s3
;
proc print;
   title2 'CALENDAR Data Set';
   run;


data holidays;
   format holiday holifin date7.;
   input holiday date8. holifin date8. holidur;
   datalines;
24dec03 26dec03 4
01jan04 01jan04  .
;

title 'Multiple Calendars';
title2 'Holidays Data Set';
proc print;
   run;

/* To visualize the breaks, use following "dummy" data set
 to plot a schedule bar showing holidays and breaks for
 each calendar */
data cals;
e_start='1dec03:00:00'dt;
e_finish='4jan04:08:00'dt;
label cal ='Schedule Breaks / Holidays';
format e_start e_finish datetime16.;
length cal $8.;
cal='DEFAULT' ; output;
cal='PROD_CAL'; output;
cal='OVT_CAL' ; output;
run;


goptions hsize=5.75 in vsize=2 in;
goptions hpos=160 vpos=25;
pattern1 v=e c=black r=6;
pattern2 v=s c=black;


goptions hpos=160 vpos=25;
title h=2 'Multiple Calendars';
title2 h=1.4 'Breaks and Holidays for the Different Calendars';
proc gantt data=cals graphics
           calendar=calendar holidata=holidays
           workday=workdata;
   chart / interval=dtday mininterval=dthour skip=2
           holiday=(holiday) holifin=(holifin)
           markbreak daylength='08:00't calid=cal
           ref='1dec03:00:00'dt to '4jan04:08:00'dt by dtday
           nolegend nojobnum increment=16
           hpages=6;
   id cal;
   run;


data widgcal;
   set widget9;
   if task = 'Production' then       cal = 'PROD_CAL';
   else if task = 'Prototype' then   cal = 'OVT_CAL';
   else                              cal = 'DEFAULT';
   run;

proc cpm date='01dec03'd data=widgcal out=scheddef
         holidata=holidays daylength='08:00't
         workday=workdata
         calendar=calendar;
   holiday holiday / holifin = holifin;
   activity task;
   duration days;
   successor succ1 succ2 succ3;
   run;

title2 'Project Schedule: Default calendar';
proc print heading=h;
   var task days e_start e_finish l_start l_finish
       t_float f_float;
   run;


proc cpm date='01dec03'd data=widgcal out=schedmc
         holidata=holidays daylength='08:00't
         workday=workdata
         calendar=calendar;
   holiday holiday / holifin = holifin;
   activity task;
   duration days;
   successor succ1 succ2 succ3;
   calid cal;
   run;
title2 'Project Schedule: Three Calendars';
proc print;
   var task days cal e_: l_: t_float f_float;
   run;

data holidata;
   format holiday holifin date7.;
   input holiday date8. holifin date8. holidur cal $;
   datalines;
08dec03 .        7  Eng_cal
24dec03 26dec03  .  .
01jan04 01jan04  .  .
;

title 'Multiple Calendars';
proc print;
   title2 'Holidays Data Set';
   run;

data caledata;
   input  cal $ _sun_ $ _mon_$ _tue_$  _wed_$ _thu_$ _fri_$ _sat_ $;
   datalines;
DEFAULT  holiday fullday fullday fullday fullday fullday holiday
OVT_CAL  holiday ovtday  ovtday  ovtday  ovtday  ovtday  halfday
PROD_CAL holiday s2      s1      s1      s1      s1      s3
Eng_cal  .       .       .       .       .       .       .
;
proc print;
   title2 'Calendar Data Set';
run;

/* Create a data set to illustrate holidays with PROC GANTT */
data cals2;
   e_start='1dec03:00:00'dt;
   e_finish='18dec03:00:00'dt;
   label cal ='Schedule Breaks / Holidays';
   format e_start e_finish datetime16.;
   length cal $8.;
   cal='DEFAULT' ; output;
   cal='Eng_cal' ; output;
   run;

title2 'Breaks and Holidays for Eng_cal and the DEFAULT Calendar';
proc gantt data=cals2 graphics
           calendar=caledata holidata=holidata
           workday=workdata;
   chart / interval=dtday mininterval=dthour skip=2
           holiday=(holiday) holifin=(holifin) holidur=(holidur)
           markbreak daylength='08:00't calid=cal
           ref='1dec03:00:00'dt to '18dec03:00:00'dt by dtday
           nojobnum nolegend increment=16 hpages=3;
   id cal;
   run;

data widgvac;
   set widgcal;
   if task = 'Write Specs' then cal = 'Eng_cal';
   run;

proc cpm date='01dec03'd data=widgvac out=schedvac
         holidata=holidata daylength='08:00't
         workday=workdata
         calendar=caledata;
   holiday holiday / holifin = holifin holidur=holidur;
   activity task;
   duration days;
   successor succ1 succ2 succ3;
   calid cal;
   run;

title2 'Project Schedule: Four Calendars';
proc print;
   var task days cal e_: l_: t_float f_float;
   run;