CALENDAR Procedure

Example 8: Multiple Summary Calendars with Atypical Work Shifts (Separated Output)

Features:
PROC CALENDAR statement options:
DATETIME
LEGEND
CALID statement:
_CAL_ variable
OUTPUT=SEPARATE option
Other statements:
OUTSTART statement
OUTFIN statement
SUM statement
Data sets: WELL.ACT

WELL.HOL

Details

This example does the following:
  • produces a summary calendar for multiple calendars in a single PROC step
  • prints the calendars on separate pages
  • displays holidays
  • uses separate work patterns, work shifts, and holidays for each calendar

Producing Different Output for Multiple Calendars

This example produces separate output for multiple calendars. To produce combined or mixed output for this data, you need to change only the following two things:
  • how the activities data set is sorted
  • 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

libname well
'SAS-library';
run;
proc sort data=well.act;
   by _cal_ date;
run;
options formchar="|----|+|---+=|-/\<>*" linesize=132;
proc calendar data=well.act
              holidata=well.hol
              datetime legend;
   calid _cal_ / output=separate;
   start date;
   holistart date;
   holivar holiday;
   sum cost / format=dollar10.2;
   outstart Monday;
   outfin Saturday;
   title 'Well Drilling Cost Summary';
   title2 'Separate Calendars';
   format cost dollar10.2;
run;

Program Description

Specify the SAS library where the activities data set is stored.
libname well
'SAS-library';
run;
Sort the activities data set by the variables containing the calendar identification and the starting date, respectively.
proc sort data=well.act;
   by _cal_ 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. LINESIZE needs to be set in this example to prevent truncating data in the output.
options formchar="|----|+|---+=|-/\<>*" linesize=132;
Create the summary calendar. DATA= identifies the activities data set; HOLIDATA= identifies the holidays data set; CALDATA= identifies the calendar data set; WORKDATA= identifies the workdays data set. DATETIME specifies that the variable specified with the START statement contains a SAS datetime value. LEGEND prints text that identifies the variables.
proc calendar data=well.act
              holidata=well.hol
              datetime legend;
Print each calendar on a separate page. The CALID statement specifies that the _CAL_ variable identifies calendars. OUTPUT=SEPARATE prints information for each calendar on separate pages.
   calid _cal_ / output=separate;
Specify an activity start date variable and retrieve holiday information. The START statement specifies the variable in the activities data set that contains the activity starting date. The HOLISTART and HOLIVAR statements specify the variables in the holidays data set that contain the start date and name of each holiday, respectively. These statements are required when you use a holidays data set.
   start date;
   holistart date;
   holivar holiday;
Calculate sum values. The SUM statement totals the COST variable for all observations in each calendar.
   sum cost / format=dollar10.2;
Display a 6-day week. OUTSTART and OUTFIN specify that the calendar display a 6-day week, Monday through Saturday.
   outstart Monday;
   outfin Saturday;
Specify the titles and format the Cost variable.
   title 'Well Drilling Cost Summary';
   title2 'Separate Calendars';
   format cost dollar10.2;
run;

Output: HTML

Well Drilling Cost Summary, CAL1
Well Drilling Cost Summary, CAL2