CALENDAR Procedure

Example 6: Calculating a Schedule Based on Completion of Predecessor Tasks

Features:
PROC CALENDAR procedure features:
PROC CALENDAR statement
CALID statement
FIN statement
VAR statement
Other features:
:
PROC CPM step
PROC SORT step

Details

Program Description

This example does the following:
  • calculates a project schedule containing multiple calendars (PROC CPM)
  • produces a listing of the PROC CPM output data set (PROC PRINT)
  • displays the schedule in calendar format (PROC CALENDAR)
This example features PROC CPM's ability to calculate a schedule that meets the following criteria:
  • is based on an initial starting date
  • applies different non-work periods to different calendars, such as personal vacation days to each employee's schedule
  • includes milestones (activities with a duration of 0)

Automating Your Scheduling Task with SAS/OR Software

When changes occur to a schedule, you have to adjust the activity starting dates manually if you use PROC CALENDAR to produce a schedule calendar. Alternatively, you can use PROC CPM in SAS/OR software to reschedule work when dates change. Even more important, you can provide only an initial starting date for a project and let PROC CPM calculate starting dates for activities, based on identified successor tasks, that is, tasks that cannot begin until their predecessors end.
In order to use PROC CPM, you must complete the following steps:
  1. Create an activities data set that contains activities with durations. (You can indicate nonwork days, weekly work schedules, and work shifts with holidays, calendar, and work-shift data sets.)
  2. Indicate which activities are successors to others (precedence relationships).
  3. Define resource limitations if you want them considered in the schedule.
  4. Provide an initial starting date.
PROC CPM can process your data to generate a data set that contains the start and end dates for each activity. PROC CPM schedules the activities, based on the duration information, weekly work patterns, work shifts, as well as holidays and nonwork days that interrupt the schedule. You can generate several views of the schedule that is computed by PROC CPM, from a simple listing of start and finish dates to a calendar, a Gantt chart, or a network diagram.

See Also

This example introduces users of PROC CALENDAR to more advanced SAS scheduling tools. For an introduction to project management tasks and tools and several examples, see Project Management Using the SAS System. For more examples, see SAS/OR Software: Project Management Examples. For complete reference documentation, see SAS/OR(R) 9.3 User's Guide: Mathematical Programming.

Program

options formchar="|----|+|---+=|-/\<>*";
data grant;
   input jobnum Task $ 4-22 Days Succ1 $ 27-45 aldate : date7. altype $
         _cal_ $;
   format aldate date7.;
   datalines;
1  Run Exp 1          11  Analyze Exp 1       .      .   Student
2  Analyze Exp 1       5  Send Report 1       .      .   Prof.
3  Send Report 1       0  Run Exp 2           .      .   Prof.
4  Run Exp 2          11  Analyze Exp 2       .      .   Student
5  Analyze Exp 2       4  Send Report 2       .      .   Prof.
6  Send Report 2       0  Write Final Report  .      .   Prof.
7  Write Final Report  4  Send Final Report   .      .   Prof.
8  Send Final Report   0                      .      .   Student
9  Site Visit          1                     18jul07 ms  Prof.
;
data nowork;
   format holista date7. holifin date7.;
   input holista : date7. holifin : date7. name $ 17-32 _cal_ $;
   datalines;
04jul07 04jul07 Independence Day Prof.
03sep07 03sep07 Labor Day        Prof.
04jul07 04jul07 Independence Day Student
03sep07 03sep07 Labor Day        Student
16jul07 17jul07 PROF Vacation    Prof.
16aug07 17aug07 STUDENT Vacation Student
;
proc cpm data=grant
         date='01jul07'd
         interval=weekday
         out=gcpm1
         holidata=nowork;
   activity task;
   successor succ1;
   duration days;
   calid _cal_;
   id task;
   aligndate aldate;
   aligntype altype;
   holiday holista / holifin=holifin;
run;
proc print data=gcpm1;
   title 'Data Set GCPM1, Created with PROC CPM';
run;
proc sort data=gcpm1;
   by e_start;
run;
proc calendar data=gcpm1
              holidata=nowork
              interval=workday;
   start e_start;
   fin   e_finish;
   calid _cal_ / output=combine;
   holistart holista;
   holifin   holifin;
   holivar name;
   var task;
   title 'Schedule for Experiment X-15';
   title2 'Professor and Student Schedule';
run;

Program Description

Set the FORMCHAR option.Setting FORMCHAR to this exact string renders better HTML output when it is viewed outside of the SAS environment where SAS Monospace fonts are not available.
options formchar="|----|+|---+=|-/\<>*";
Create the activities data set and identify separate calendars. This data identifies two calendars: the professor's (the value of _CAL_ is Prof.) and the student's (the value of _CAL_ is Student). The Succ1 variable identifies which activity cannot begin until the current one ends. For example Analyze Exp 1 cannot begin until Run Exp 1 is completed. The DAYS value of 0 for JOBNUM 3, 6, and 8 indicates that these jobs are milestones.
data grant;
   input jobnum Task $ 4-22 Days Succ1 $ 27-45 aldate : date7. altype $
         _cal_ $;
   format aldate date7.;
   datalines;
1  Run Exp 1          11  Analyze Exp 1       .      .   Student
2  Analyze Exp 1       5  Send Report 1       .      .   Prof.
3  Send Report 1       0  Run Exp 2           .      .   Prof.
4  Run Exp 2          11  Analyze Exp 2       .      .   Student
5  Analyze Exp 2       4  Send Report 2       .      .   Prof.
6  Send Report 2       0  Write Final Report  .      .   Prof.
7  Write Final Report  4  Send Final Report   .      .   Prof.
8  Send Final Report   0                      .      .   Student
9  Site Visit          1                     18jul07 ms  Prof.
;
Create the holidays data set and identify which calendar a nonwork day belongs to. The two holidays are listed twice, once for the professor's calendar and once for the student's. Because each person is associated with a separate calendar, PROC CPM can apply the personal vacation days to the appropriate calendars.
data nowork;
   format holista date7. holifin date7.;
   input holista : date7. holifin : date7. name $ 17-32 _cal_ $;
   datalines;
04jul07 04jul07 Independence Day Prof.
03sep07 03sep07 Labor Day        Prof.
04jul07 04jul07 Independence Day Student
03sep07 03sep07 Labor Day        Student
16jul07 17jul07 PROF Vacation    Prof.
16aug07 17aug07 STUDENT Vacation Student
;
Calculate the schedule with PROC CPM. PROC CPM uses information supplied in the activities and holidays data sets to calculate start and finish dates for each activity. The DATE= option supplies the starting date of the project. The CALID statement is not required, even though this example includes two calendars, because the calendar identification variable has the special name _CAL_.
proc cpm data=grant
         date='01jul07'd
         interval=weekday
         out=gcpm1
         holidata=nowork;
   activity task;
   successor succ1;
   duration days;
   calid _cal_;
   id task;
   aligndate aldate;
   aligntype altype;
   holiday holista / holifin=holifin;
run;
Print the output data set that was created with PROC CPM. This step is not required. PROC PRINT is a useful way to view the calculations produced by PROC CPM.
proc print data=gcpm1;
   title 'Data Set GCPM1, Created with PROC CPM';
run;
Sort GCPM1 by the variable that contains the activity start dates before using it with PROC CALENDAR.
proc sort data=gcpm1;
   by e_start;
run;
Create the schedule calendar. GCPM1 is the activity data set. PROC CALENDAR uses the S_START and S_FINISH dates, calculated by PROC CPM, to print the schedule. The VAR statement selects only the variable TASK to display on the calendar output.
proc calendar data=gcpm1
              holidata=nowork
              interval=workday;
   start e_start;
   fin   e_finish;
   calid _cal_ / output=combine;
   holistart holista;
   holifin   holifin;
   holivar name;
   var task;
   title 'Schedule for Experiment X-15';
   title2 'Professor and Student Schedule';
run;

Output: HTML

PROC PRINT displays the observations in GCPM1, showing the scheduling calculations created by PROC CPM.
Data Set GCPM1, Created with PROC CPM
PROC CALENDAR created the following schedule calendar by using the S_START and S_FINISH dates that were calculated by PROC CPM. The activities on July 25 and August 15, because they are milestones, do not delay the start of a successor activity. Note that Site Visit occurs on July 18, the same day that Analyze Exp 1 occurs. To prevent this overallocation of resources, you can use resource constrained scheduling, available in SAS/OR software.
Schedule for Experiment X-15, July
Schedule for Experiment X-15, August