CALENDAR Procedure

PROC CALENDAR Statement

Displays data from a SAS data set in a monthly calendar format.
Schedule Calendar with Holidays: 5-Day Default

Multiple Schedule Calendars with Atypical Work Shifts (Separated Output)

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

Schedule Calendar, Blank or with Holidays

Calculating a Schedule Based on Completion of Predecessor Tasks

Multiple Summary Calendars with Atypical Work Shifts (Separated Output)

Syntax

PROC CALENDAR <option(s)>;

Summary of Optional Arguments

Control printing
displays all months, even if no activities exist.
defines characters used for outlines, dividers, and so on.
specifies the type of heading to use in printing the name of the month.
displays month and weekday names in the local language.
specifies how to show missing values.
suppresses the display of Saturdays and Sundays in the output.
Control summary information
prints the names of the variables whose values appear in the calendar.
specifies the type of mean to calculate for each month.
Specify data sets containing
weekly work schedules
activities
holidays
unique shift patterns
Specify time or duration
specifies that START and FIN variables contain values in DATETIME. format.
specifies the number of hours in a standard work day.
specifies the units of the DUR and HOLIDUR variables.

Optional Arguments

CALEDATA=SAS-data-set
specifies the calendar data set, a SAS data set that contains weekly work schedules for multiple calendars.
Default:If you omit the CALEDATA= option, then PROC CALENDAR uses a default work schedule.
Tip:A calendar data set is useful if you are using multiple calendars or a nonstandard work schedule.

Calendar Data Set

DATA=SAS-data-set
specifies the activities data set, a SAS data set that contains starting dates for all activities and variables to display for each activity. Activities must be sorted or indexed by starting date.
Default:If you omit the DATA= option, then the most recently created SAS data set is used.
DATETIME
specifies that START and FIN variables contain values in DATETIME. format.
DAYLENGTH=hours
The hour value must be a SAS TIME value.
Default:24 if INTERVAL=DAY (the default), 8 if INTERVAL=WORKDAY.
Restriction:DAYLENGTH= applies only to schedule calendars.
Interactions:If you specify the DAYLENGTH= option and the calendar data set contains a D_LENGTH variable, then PROC CALENDAR uses the DAYLENGTH= value only when the D_LENGTH value is missing.

When INTERVAL=DAY and you have no CALEDATA= data set, specifying a DAYLENGTH= value has no effect.

Tips:The DAYLENGTH= option is useful when you use the DUR statement and your work schedule contains days of varying lengths (for example, a work week of five half-days). In a work week with varying day lengths, you need to set a standard day length to use in calculating duration times. For example, an activity with a duration of 3.0 workdays lasts 24 hours if DAYLENGTH=8:00 or 30 hours if DAYLENGTH=10:00.

Instead of specifying the DAYLENGTH= option, you can specify the length of the working day by using a D_LENGTH variable in the CALEDATA= data set. If you use this method, then you can specify different standard day lengths for different calendars.

See:Calendar Data Set for more information about setting the length of the standard workday
FILL
displays all months between the first and last activity, start and finish dates inclusive, including months that contain no activities.
Default:If you do not specify FILL, then PROC CALENDAR prints only months that contain activities. (Months that contain only holidays are not printed.)
FORMCHAR <(position(s))>='formatting-character(s)'
defines the characters to use for constructing the outlines and dividers for the cells in the calendar as well as all identifying markers (such as asterisks and arrows) used to indicate holidays or continuation of activities in PROC CALENDAR output.
position(s)
identifies the position of one or more characters in the SAS formatting-character string. A space or a comma separates the positions.
Default:Omitting (position(s)) is the same as specifying all 20 possible system formatting characters, in order.
Range:PROC CALENDAR uses 17 of the 20 formatting characters that SAS provides.
See:Formatting Characters Used by PROC CALENDAR shows the formatting characters that PROC CALENDAR uses.

Formatting Characters in PROC CALENDAR Output illustrates their use in PROC CALENDAR output.

formatting-character(s)
lists the characters to use for the specified positions. PROC CALENDAR assigns characters in formatting-character(s) to position(s), in the order in which they are listed. For example, the following option assigns an asterisk (*) to the 12th position, assigns a single hyphen (-) to the 13th, and does not alter remaining characters:
formchar(12 13)='*-'
These new settings change the activity line from this:
+=================ACTIVITY===============+
to this:
*------------------ACTIVITY--------------*
Formatting Characters in PROC CALENDAR Output
Formatting Characters in PROC CALENDAR Output
Formatting Characters Used by PROC CALENDAR
Position
Default
Used to Draw
1
|
Vertical bar
2
-
Horizontal bar
3
-
Cell: upper left corner
4
-
Cell: upper middle intersection
5
-
Cell: upper right corner
6
|
Cell: middle left cell side
7
+
Cell: middle middle intersection
8
|
Cell: middle right cell side
9
-
Cell: lower left corner
10
-
Cell: lower middle intersection
11
-
Cell: lower right corner
12
+
Activity start and finish
13
=
Activity line
16
/
Activity separator
18
<
Activity continuation from
19
>
Activity continuation to
20
*
Holiday marker
Interaction:The SAS system option FORMCHAR= specifies the default formatting characters. The SAS system option defines the entire string of formatting characters. The FORMCHAR= option in a procedure can redefine selected characters.
Tip: You can use any character in formatting-characters, including hexadecimal characters. If you use hexadecimal characters, then you must put an x after the closing quotation mark. For example, the following option assigns the hexadecimal character 2-D to the third formatting character, the hexadecimal character 7C to the seventh character, and does not alter the remaining characters: formchar(3,7)='2D7C'x
See:For information about which hexadecimal codes to use for which characters, consult the documentation for your hardware.
HEADER=SMALL | MEDIUM | LARGE
specifies the type of heading to use in printing the name of the month.
SMALL
prints the month and year on one line.
MEDIUM
prints the month and year in a box four lines high.
LARGE
prints the month seven lines high using asterisks (*). The year is included if space is available.
Default:MEDIUM
HOLIDATA=SAS-data-set
specifies the holidays data set, a SAS data set that contains the holidays that you want to display in the output. One variable must contain the holiday names and another must contain the starting dates for each holiday. PROC CALENDAR marks holidays in the calendar output with asterisks (*) when space permits.
Interaction:Displaying holidays on a calendar requires a holidays data set and a HOLISTART statement. A HOLIVAR statement is recommended for naming holidays. HOLIDUR is required if any holiday lasts longer than one day.
Tip:The holidays data set does not require sorting.
INTERVAL=DAY | WORKDAY
specifies the units of the DUR and HOLIDUR variables to one of two default daylengths:
DAY
specifies the values of the DUR and HOLIDUR variables in units of 24-hour days and specifies the default 7-day calendar. For example, a DUR value of 3.0 is treated as 72 hours. The default calendar work schedule consists of seven working days, all starting at 00:00 with a length of 24:00.
WORKDAY
specifies the values of the DUR and HOLIDUR variables in units of 8-hour days. WORKDAY also specifies that the default calendar contains five days a week, Monday through Friday, all starting at 09:00 with a length of 08:00. When WORKDAY is specified, PROC CALENDAR treats the values of the DUR and HOLIDUR variables in units of working days, as defined in the DAYLENGTH= option, the CALEDATA= data set, or the default calendar. For example, if the working day is eight hours long, then a DUR value of 3.0 is treated as 24 hours.
Default:DAY
Interactions:If there is no CALEDATA= data set, PROC CALENDAR uses the work schedule defined in a default calendar.

The WEEKDAYS option automatically sets the INTERVAL= value to WORKDAY.

See:Calendars and Multiple Calendars and Calendar Data Set for more information about the INTERVAL= option and the specification of working days; The Default Calendars
LEGEND
prints the names of the variables whose values appear in the calendar. This identifying text, or legend box, appears at the bottom of the page for each month if space permits. Otherwise, it is printed on the following page. PROC CALENDAR identifies each variable by name or by label if one exists. The order of variables in the legend matches their order in the calendar.
Restriction:LEGEND applies only to summary calendars.
Interaction:If you use the SUM and MEAN statements, then the legend box also contains SUM and MEAN values.
LOCALE
prints the names of months and weekdays in the language that is indicated by the value of the LOCALE= SAS system option. The LOCALE option in PROC CALENDAR does not change the starting day of the week.
Default:If LOCALE is not specified, then names of months and weekdays are printed in English.
MEANTYPE=NOBS | NDAYS
specifies the type of mean to calculate for each month.
NOBS
calculates the mean over the number of observations displayed in the month.
NDAYS
calculates the mean over the number of days displayed in the month.
Default:NOBS
Restriction:MEANTYPE= applies only to summary calendars.
Interaction:Normally, PROC CALENDAR displays all days for each month. However, it might omit some days if you use the OUTSTART statement with the OUTDUR or OUTFIN statement.
MISSING
determines how missing values are treated, based on the type of calendar.
Summary Calendar
If there is a day without an activity scheduled, then PROC CALENDAR prints the values of variables for that day by using the SAS or user-defined that is format specified for missing values.
Default:If you omit MISSING, then days without activities contain no values.
Schedule Calendar
variables with missing values appear in the label of an activity, using the format specified for missing values.
Default:If you do not specify MISSING, then PROC CALENDAR ignores missing values in labeling activities.
See:Missing Values in Input Data Sets for more information about missing values
WEEKDAYS
suppresses the display of Saturdays and Sundays in the output. It also specifies that the value of the INTERVAL= option is WORKDAY.
  proc calendar weekdays;
    start date; 
run;  
proc calendar interval=workday;
    start date;    
outstart monday;    
outfin friday; 
run;
Default:If you omit WEEKDAYS, then the calendar displays all seven days.
Tip:The WEEKDAYS option is an alternative to using the combination of INTERVAL=WORKDAY and the OUTSTART and OUTFIN statements, as shown here:
WORKDATA=SAS-data-set
specifies the workdays data set, a SAS data set that defines the work pattern during a standard working day. Each numeric variable in the workdays data set denotes a unique work-shift pattern during one working day.