The CPM Procedure

Example 4.6 Changing Duration Units

This example illustrates the use of the INTERVAL= option to identify the units of duration to PROC CPM. In the previous examples, it was assumed that work can be done on the activities all seven days of the week without any break. Suppose now that you want to schedule the activities only on weekdays. To do so, specify INTERVAL=WEEKDAY in the PROC CPM statement. Output 4.6.1 displays the schedule produced by PROC CPM. Note that, with a shorter work week, the project finishes on March 8, 2004, instead of on February 9, 2004.


proc cpm data=widget out=save
     date='1dec03'd interval=weekday;
   activity task;
   succ     succ1 succ2 succ3;
   duration days;
   run;

title 'Changing Duration Units';
title2 'INTERVAL=WEEKDAY';
proc print;
   id task;
   var e_: l_: t_float f_float;
   run;

Output 4.6.1: Changing Duration Units: INTERVAL=WEEKDAY

Changing Duration Units
INTERVAL=WEEKDAY

task E_START E_FINISH L_START L_FINISH T_FLOAT F_FLOAT
Approve Plan 01DEC03 05DEC03 01DEC03 05DEC03 0 0
Drawings 08DEC03 19DEC03 08DEC03 19DEC03 0 0
Study Market 08DEC03 12DEC03 19JAN04 23JAN04 30 0
Write Specs 08DEC03 12DEC03 15DEC03 19DEC03 5 5
Prototype 22DEC03 09JAN04 22DEC03 09JAN04 0 0
Mkt. Strat. 15DEC03 26DEC03 26JAN04 06FEB04 30 30
Materials 12JAN04 23JAN04 12JAN04 23JAN04 0 0
Facility 12JAN04 23JAN04 12JAN04 23JAN04 0 0
Init. Prod. 26JAN04 06FEB04 26JAN04 06FEB04 0 0
Evaluate 09FEB04 20FEB04 16FEB04 27FEB04 5 5
Test Market 09FEB04 27FEB04 09FEB04 27FEB04 0 0
Changes 01MAR04 05MAR04 01MAR04 05MAR04 0 0
Production 08MAR04 08MAR04 08MAR04 08MAR04 0 0
Marketing 09FEB04 09FEB04 08MAR04 08MAR04 20 20


To display the weekday schedule on a calendar, use the WEEKDAY option in the PROC CALENDAR statement. The following code sorts the Schedule data set by the E_START variable and produces a calendar shown in Output 4.6.2, which displays the schedule of activities for the month of December.

proc sort;
   by e_start;
   run;

/* truncate schedule: print only for december */
data december;
   set save;
   e_finish = min('31dec03'd, e_finish);
   if e_start <= '31dec03'd;
   run;

title3 'Calendar of Schedule';
options nodate pageno=1 ps=50;
proc calendar data=december schedule weekdays;
   id e_start;
   finish e_finish;
   var task;
   run;

Output 4.6.2: Changing Duration Units: WEEKDAY Calendar for December

Changing Duration Units
INTERVAL=WEEKDAY
Calendar of Schedule

--------------------------------------------------------------------------------- 
|                                                                               | 
|                                December  2003                                 | 
|                                                                               | 
|-------------------------------------------------------------------------------| 
|    Monday     |    Tuesday    |   Wednesday   |   Thursday    |    Friday     | 
|---------------+---------------+---------------+---------------+---------------| 
|       1       |       2       |       3       |       4       |       5       | 
|               |               |               |               |               | 
|               |               |               |               |               | 
|               |               |               |               |               | 
|               |               |               |               |               | 
|+================================Approve Plan=================================+| 
|---------------+---------------+---------------+---------------+---------------| 
|       8       |       9       |      10       |      11       |      12       | 
|               |               |               |               |               | 
|               |               |               |               |               | 
|+=================================Write Specs=================================+| 
|+================================Study Market=================================+| 
|+==================================Drawings===================================>| 
|---------------+---------------+---------------+---------------+---------------| 
|      15       |      16       |      17       |      18       |      19       | 
|               |               |               |               |               | 
|               |               |               |               |               | 
|               |               |               |               |               | 
|+=================================Mkt. Strat.=================================>| 
|<==================================Drawings===================================+| 
|---------------+---------------+---------------+---------------+---------------| 
|      22       |      23       |      24       |      25       |      26       | 
|               |               |               |               |               | 
|               |               |               |               |               | 
|               |               |               |               |               | 
|+==================================Prototype==================================>| 
|<=================================Mkt. Strat.=================================+| 
|---------------+---------------+---------------+---------------+---------------| 
|      29       |      30       |      31       |               |               | 
|               |               |               |               |               | 
|               |               |               |               |               | 
|               |               |               |               |               | 
|               |               |               |               |               | 
|<==================Prototype==================+|               |               | 
--------------------------------------------------------------------------------- 


The durations of the activities in the project are multiples of 5. Thus, if work is done only on weekdays, all activities in the project last 0, 1, 2, or 3 weeks. The INTERVAL= option can also be used to set the units of duration to hours, minutes, seconds, years, months, quarters, or weeks. In this example, the data set WIDGWK is created from WIDGET to set the durations in weeks. PROC CPM is then invoked with INTERVAL=WEEK, and the resulting schedule is displayed in Output 4.6.3. Note that the float values are also expressed in units of weeks.

data widgwk;
   set widget;
   weeks = days / 5;
   run;

proc cpm data=widgwk date='1dec03'd interval=week;
   activity  task;
   successor succ1 succ2 succ3;
   duration  weeks;
   id task;
   run;

title2 'INTERVAL=WEEK';
proc print;
   id task;
   var e_: l_: t_float f_float;
   run;

Output 4.6.3: Changing Duration Units: INTERVAL=WEEK

Changing Duration Units
INTERVAL=WEEK

task E_START E_FINISH L_START L_FINISH T_FLOAT F_FLOAT
Approve Plan 01DEC03 07DEC03 01DEC03 07DEC03 0 0
Drawings 08DEC03 21DEC03 08DEC03 21DEC03 0 0
Study Market 08DEC03 14DEC03 19JAN04 25JAN04 6 0
Write Specs 08DEC03 14DEC03 15DEC03 21DEC03 1 1
Prototype 22DEC03 11JAN04 22DEC03 11JAN04 0 0
Mkt. Strat. 15DEC03 28DEC03 26JAN04 08FEB04 6 6
Materials 12JAN04 25JAN04 12JAN04 25JAN04 0 0
Facility 12JAN04 25JAN04 12JAN04 25JAN04 0 0
Init. Prod. 26JAN04 08FEB04 26JAN04 08FEB04 0 0
Evaluate 09FEB04 22FEB04 16FEB04 29FEB04 1 1
Test Market 09FEB04 29FEB04 09FEB04 29FEB04 0 0
Changes 01MAR04 07MAR04 01MAR04 07MAR04 0 0
Production 08MAR04 08MAR04 08MAR04 08MAR04 0 0
Marketing 09FEB04 09FEB04 08MAR04 08MAR04 4 4