CALENDAR Procedure

Example 2: Schedule Calendar Containing Multiple Calendars

Features:
CALID statement:
_CAL_ variable
OUTPUT=COMBINE option
Others:
DUR statement
24-hour day, 7-day week

Details

This example builds on Example 1 by identifying activities as belonging to one of two calendars, business or personal. This example does the following:
  • produces a schedule calendar report
  • prints two calendars on the same output page
  • schedules activities around holidays
  • uses one of the two default work patterns: 24-hour day, 7-day week
  • identifies activities and holidays by calendar name

Program

data allacty2;
  input date:date7. happen $ 10-34 who $ 35-47 _CAL_ $ long;
  datalines;
01JUL02  Dist. Mtg.               All          CAL1   1
02JUL02  Mgrs. Meeting            District 6   CAL1   2
03JUL02  Interview                JW           CAL1   1
05JUL02  VIP Banquet              JW           CAL1   1
06JUL02  Beach trip               family       CAL2   2
08JUL02  Sales Drive              District 6   CAL1   5
08JUL02  Trade Show               Knox         CAL1   3
09JUL02  Orthodontist             Meagan       CAL2   1
11JUL02  Mgrs. Meeting            District 7   CAL1   2
11JUL02  Planning Council         Group II     CAL1   1
12JUL02  Seminar                  White        CAL1   1
14JUL02  Co. Picnic               All          CAL1   1
14JUL02  Business trip            Fred         CAL2   2
15JUL02  Sales Drive              District 7   CAL1   5
16JUL02  Dentist                  JW           CAL1   1
17JUL02  Bank Meeting             1st Natl     CAL1   1
17JUL02  Real estate agent        Family       CAL2   1
18JUL02  NewsLetter Deadline      All          CAL1   1
18JUL02  Planning Council         Group III    CAL1   1
19JUL02  Seminar                  White        CAL1   1
22JUL02  Inventors Show           Melvin       CAL1   3
24JUL02  Birthday                 Mary         CAL1   1
25JUL02  Planning Council         Group IV     CAL1   1
25JUL02  Close Sale               WYGIX Co.    CAL1   2
27JUL02  Ballgame                 Family       CAL2   1
;
data vac;
   input hdate:date7.  holiday $ 11-25 _CAL_ $ ;
   datalines;
29JUL02   vacation                CAL2
04JUL02   Independence            CAL1
;
proc sort data=allacty2;
   by date;
run;
options formchar="|----|+|---+=|-/\<>*"; 
proc calendar data=allacty2 holidata=vac;
   calid _CAL_ / output=combine;
   start date ;
   dur long;
   holistart hdate;
   holivar holiday;
   title1 'Summer Planning Calendar:  Julia Cho';
   title2 'President, Community Bank';
   title3 'Work and Home Schedule';
run;

Program Description

Create the activities data set and identify separate calendars. ALLACTY2 contains both personal and business activities for a bank president. The _CAL_ variable identifies which calendar an event belongs to.
data allacty2;
  input date:date7. happen $ 10-34 who $ 35-47 _CAL_ $ long;
  datalines;
01JUL02  Dist. Mtg.               All          CAL1   1
02JUL02  Mgrs. Meeting            District 6   CAL1   2
03JUL02  Interview                JW           CAL1   1
05JUL02  VIP Banquet              JW           CAL1   1
06JUL02  Beach trip               family       CAL2   2
08JUL02  Sales Drive              District 6   CAL1   5
08JUL02  Trade Show               Knox         CAL1   3
09JUL02  Orthodontist             Meagan       CAL2   1
11JUL02  Mgrs. Meeting            District 7   CAL1   2
11JUL02  Planning Council         Group II     CAL1   1
12JUL02  Seminar                  White        CAL1   1
14JUL02  Co. Picnic               All          CAL1   1
14JUL02  Business trip            Fred         CAL2   2
15JUL02  Sales Drive              District 7   CAL1   5
16JUL02  Dentist                  JW           CAL1   1
17JUL02  Bank Meeting             1st Natl     CAL1   1
17JUL02  Real estate agent        Family       CAL2   1
18JUL02  NewsLetter Deadline      All          CAL1   1
18JUL02  Planning Council         Group III    CAL1   1
19JUL02  Seminar                  White        CAL1   1
22JUL02  Inventors Show           Melvin       CAL1   3
24JUL02  Birthday                 Mary         CAL1   1
25JUL02  Planning Council         Group IV     CAL1   1
25JUL02  Close Sale               WYGIX Co.    CAL1   2
27JUL02  Ballgame                 Family       CAL2   1
;
Create the holidays data set and identify which calendar a holiday affects. The _CAL_ variable identifies which calendar a holiday belongs to.
data vac;
   input hdate:date7.  holiday $ 11-25 _CAL_ $ ;
   datalines;
29JUL02   vacation                CAL2
04JUL02   Independence            CAL1
;
Sort the activities data set by the variable that contains the starting date. When creating a calendar with combined output, you sort only by the activity starting date, not by the CALID variable. You are not required to sort the holidays data set.
proc sort data=allacty2;
   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. By default, the output calendar displays a 7-day week.
proc calendar data=allacty2 holidata=vac;
Combine all events and holidays on a single calendar. The CALID statement specifies the variable that identifies which calendar an event belongs to. OUTPUT=COMBINE places all events and holidays on the same 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. Creating a schedule calendar requires START and DUR.
   start date ;
   dur long;
Retrieve holiday information. The HOLISTART and HOLIVAR statements 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 hdate;
   holivar holiday;
Specify the titles.
   title1 'Summer Planning Calendar:  Julia Cho';
   title2 'President, Community Bank';
   title3 'Work and Home Schedule';
run;

Output: HTML

Summer Planning Calendar - Work and Home Schedule