CALENDAR Procedure

Example 4: Multiple Schedule Calendars with Atypical Work Shifts (Combined and Mixed Output)

Features:
PROC CALENDAR statement options:
CALEDATA=
DATETIME
WORKDATA=
CALID statement:
_CAL_ variable
OUTPUT=COMBINE option
OUTPUT=MIXED option
Other statement:
DUR statement
OUTSTART statement
OUTFIN statement
Data sets: WELL.ACT

WELL.HOL

WELL.CAL

WELL.WOR

Details

This example does the following:
  • produces a schedule calendar
  • schedules activities around holidays
  • uses separate work patterns and holidays for each calendar
  • uses an 8-hour day, 5 1/2-day work week
  • displays and identifies multiple calendars on each calendar page (combined output)
  • displays but does not identify multiple calendars on each calendar page (mixed output)
This example creates both combined and mixed output. Producing combined or mixed calendar output requires only one change to a PROC CALENDAR step: the setting of the OUTPUT= option in the CALID statement. Combined output is produced first, then mixed output.
This example and Multiple Schedule Calendars with Atypical Work Shifts (Separated Output) use the same input data for multiple calendars to produce different output. The only differences in these programs are how the activities data set is sorted and how the OUTPUT= option is set.
Sort and OUTPUT= Settings
Print Options
Sorting Variables
OUTPUT= Settings
Examples
Separate pages for each calendar
Calendar ID and starting date
SEPARATE
3, 8
All activities on the same page and identify each calendar
Starting date
COMBINE
4, 2
All activities on the same page and NOT identify each calendar
Starting date
MIX
4

Program for Combined Characters

libname well
'SAS-library';
proc sort data=well.act;
   by date;
run;
options formchar="|----|+|---+=|-/\<>*";
proc calendar data=well.act
              holidata=well.hol
              caledata=well.cal
              workdata=well.wor
              datetime;
   calid _cal_ / output=combine;
   start date;
   dur dur;
   holistart date;
   holivar holiday;
   title1 'Well Drilling Work Schedule: Combined Calendars';
   format cost dollar9.2;
run;

Program Description

Specify the SAS library where the activities data set is stored.
libname well
'SAS-library';
Sort the activities data set by the variable that contains the starting date. Do not sort by the CALID variable when producing combined calendar output.
proc sort data=well.act;
   by date;
run;
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 schedule calendar. DATA= identifies the activities data set; HOLIDATA= identifies the holidays data set; CALEDATA= identifies the calendar data set; WORKDATA= identifies the workdays data set. DATETIME specifies that the variable specified with the START statement contains values in SAS datetime format.
proc calendar data=well.act
              holidata=well.hol
              caledata=well.cal
              workdata=well.wor
              datetime;
Combine all events and holidays on a single calendar. The CALID statement specifies that the _CAL_ variable identifies the calendars. OUTPUT=COMBINE prints multiple calendars on the same page and identifies each calendar.
   calid _cal_ / output=combine;
Specify an activity start date variable and an activity duration variable. The START statement specifies the variable in the activities data set that contains the starting date of the activities; DUR specifies the variable that contains the duration of each activity. START and DUR are required for a schedule calendar.
   start date;
   dur dur;
Retrieve holiday information. HOLISTART and HOLIVAR specify the variables in the holidays data set that contain the start date and name of each holiday, respectively. HOLISTART is required when you use a holidays data set.
   holistart date;
   holivar holiday;
Specify the title and format the Cost variable.
   title1 'Well Drilling Work Schedule: Combined Calendars';
   format cost dollar9.2;
run;

Output for Combined Calendars

Well Drilling Work Schedule: Combined Calendars

Program for Mixed Calendars

To produce mixed output instead of combined, use the same program and change the setting of the OUTPUT= option to OUTPUT=MIX:
proc calendar data=well.act
              holidata=well.hol
              caledata=well.cal
              workdata=well.wor
              datetime;
   calid _cal_ / output=mix;
   start date;
   dur dur;
   holistart date;
   holivar holiday;
   outstart Monday;
   outfin Saturday;
   title1 'Well Drilling Work Schedule: Mixed Calendars';
   format cost dollar9.2;
run;

Output for Mixed Calendars

Well Drilling Work Schedule: Mixed Calendars