Required: You must use a START statement.
Required: For schedule calendars, you must also use a DUR or a FIN statement.
Tip: If you use a DUR or FIN statement, then PROC CALENDAR produces a schedule calendar.
Tip: Supports the Output Delivery System. See Output Delivery System on page 32 for details.
ODS Table Name : Calendar
Reminder: You can use the FORMAT, LABEL, and WHERE statements as well as any global statements.
PROC CALENDAR < option(s) >;
START variable ;
BY <DESCENDING> variable-1
<DESCENDING> variable-n >
NOTSORTED>;
CALID variable
/ OUTPUT=COMBINEMIXSEPARATE>;
DUR variable ;
FIN variable ;
HOLISTART variable ;
HOLIDUR variable ;
HOLIFIN variable ;
HOLIVAR variable ;
MEAN variable(s) </ FORMAT= format-name >;
OUTSTART day-of-week ;
OUTDUR number-of-days ;
OUTFIN day-of-week ;
SUM variable(s) </ FORMAT= format-name >;
VAR variable(s) ;
The following table lists the statements and options available in the CALENDAR procedure according to function.
To do this | Use this statement |
---|---|
Create summary calendar | MEAN SUM |
Create schedule calendar | DUR or FIN |
Create multiple calendars | CALID |
Specify holidays | HOLISTART HOLIDUR HOLIFIN HOLIVAR |
Control display | OUTSTART OUTDUR OUTFIN |
Specify grouping | BY CALID |
PROC CALENDAR < option(s) >;
To do this | Use this option | |
---|---|---|
Specify data sets containing | ||
weekly work schedules | CALEDATA= | |
activities | DATA= | |
holidays | HOLIDATA= | |
unique shift patterns | WORKDATA= | |
Control printing | ||
display all months, even if no activities exist | FILL | |
define characters used for outlines, dividers , and so on | FORMCHAR= | |
specify the type of heading for months | HEADER= | |
display month and weekday names in local language (experimental) | LOCALE | |
specify how to show missing values | MISSING | |
suppress the display of Saturdays and Sundays | WEEKDAYS | |
Specify time or duration | ||
specify that START and FIN variables are in DATETIME format | DATETIME | |
specify the number of hours in a standard work day | DAYLENGTH= | |
specify the units of the DUR and HOLIDUR variables | INTERVAL= | |
Control summary information | ||
identify variables in the calendar | LEGEND | |
specify the type of mean to calculate | MEANTYPE= |
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, as described in The Default Calendars on page 103.
Tip: A calendar data set is useful if you are using multiple calendars or a nonstandard work schedule.
See also: Calendar Data Set on page 109
Featured in: Example 3 on page 122
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.
See also: Activities Data Set on page 107
Featured in: All examples. See Examples: CALENDAR Procedure on page 114
DATETIME
specifies that START and FIN variables contain values in DATETIME. format.
Default: If you omit the DATETIME option, then PROC CALENDAR assumes that the START and FIN values are in the DATE. format.
Featured in: Example 3 on page 122
DAYLENGTH= hours
gives the number of hours in a standard working day. 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.
Interaction: 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.
Interaction: When INTERVAL=DAY and you have no CALEDATA= data set, specifying a DAYLENGTH= value has no effect.
Tip: The DAYLENGTH= option is useful when you use the DUR statement and your work schedule contains days of varying lengths, for example, a 5 half-day work week. 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.
Tip: 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 also: Calendar Data Set on page 109 for more information on 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.)
Featured in: Example 5 on page 134
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. Table 5.1 on page 87 shows the formatting characters that PROC CALENDAR uses. Figure 5.1 on page 89 illustrates their use in PROC CALENDAR output.
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 |
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 that they are listed. For instance, the following option assigns an asterisk (*) to the twelfth position, assigns a single dash (-) to the thirteenth, and does not alter remaining characters:
formchar(12 13)='*-'
These new settings change the activity line from this:
+=================ACTIVITY===============+
to this:
*------------------ACTIVITY--------------*
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 instance, the following option assigns the hexadecimal character 2D 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 also: For information on 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 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.
See also: Holidays Data Set on page 108
Featured in: All examples. See Examples: CALENDAR Procedure on page 114
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 instance, 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 and 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 8 hours long, then a DUR value of 3.0 is treated as 24 hours.
Default: DAY
Interaction: In the absence of a CALEDATA= data set, PROC CALENDAR uses the work schedule defined in a default calendar.
Interaction: The WEEKDAYS option automatically sets the INTERVAL= value to WORKDAY.
See also: Calendars and Multiple Calendars on page 104 and Calendar Data Set on page 109 for more information on the INTERVAL= option and the specification of working days; The Default Calendars on page 103
Featured in: Example 5 on page 134
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.
Featured in: Example 8 on page 148
LOCALE (Experimental)
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.
CAUTION:
LOCALE is an experimental option that is available in SAS 9.1. Do not use this option in production jobs.
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 may omit some days if you use the OUTSTART statement with the OUTDUR or OUTFIN statement.
Featured in: Example 7 on page 143
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 also: Missing Values in Input Data Sets on page 112 for more information on 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.
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:
Example Code 5.1: Illustration of Formatting Characters in PROC CALENDAR Output
proc calendar weekdays; start date; run; proc calendar interval=workday; start date; outstart monday; outfin friday; run;
Featured in: Example 1 on page 114
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 workshift pattern during one working day.
Tip: The workdays data set is useful in conjunction with the calendar data set.
See also: Workdays Data Set on page 111 and Calendar Data Set on page 109
Featured in: Example 3 on page 122
Processes activities separately for each BY group , producing a separate calendar for each value of the BY variable.
Calendar type: Summary and schedule
Main discussion: BY on page 58
See also: CALID Statement on page 93
BY <DESCENDING> variable-1
<DESCENDING> variable-n >
NOTSORTED>;
variable
specifies the variable that the procedure uses to form BY groups. You can specify more than one variable, but the observations in the data set must be sorted by all the variables that you specify or have an appropriate index. Variables in a BY statement are called BY variables .
DESCENDING
specifies that the observations are sorted in descending order by the variable that immediately follows the word DESCENDING in the BY statement.
NOTSORTED
specifies that observations are not necessarily sorted in alphabetic or numeric order. The observations are grouped in another way, for example, chronological order.
When you use the CALID statement, you can process activities that apply to different calendars, indicated by the value of the CALID variable. Because you can specify only one CALID variable, however, you can create only one level of grouping. For example, if you want a calendar report to show the activities of several departments within a company, then you can identify each department with the value of the CALID variable and produce calendar output that shows the calendars for all departments.
When you use a BY statement, however, you can further divide activities into related groups. For example, you can print calendar output that groups departmental calendars by division. The observations for activities must contain a variable that identifies which department an activity belongs to and a variable that identifies the division that a department resides in. Specify the variable that identifies the department with the CALID statement. Specify the variable that identifies the division with the BY statement.
Processes activities in groups defined by the values of a calendar identifier variable.
Calendar type: Summary and schedule
Tip: Useful for producing multiple schedule calendars and for use with SAS/OR software.
See also: Calendar Data Set on page 109
Featured in: Example 2 on page 118, Example 3 on page 122, and Example 6 on page 137
CALID variable
/ OUTPUT=COMBINEMIXSEPARATE>;
variable
a character or numeric variable that identifies which calendar an observation contains data for.
Requirement: If you specify the CALID variable, then both the activities and holidays data sets must contain this variable. If either of these data sets does not contain the CALID variable, then a default calendar is used.
Interaction: SAS/OR software uses this variable to identify which calendar an observation contains data for.
Tip: You do not need to use a CALID statement to create this variable. You can include the default variable _CALID_ in the input data sets.
See also: Calendar Data Set on page 109
OUTPUT=COMBINEMIXSEPARATE
controls the amount of space required to display output for multiple calendars.
COMBINE
produces one page for each month that contains activities and subdivides each day by the CALID value.
Restriction: The input data must be sorted by or indexed on the START variable.
Featured in: Example 2 on page 118 and Example 4 on page 127
MIX
produces one page for each month that contains activities and does not identify activities by the CALID value.
Restriction: The input data must be sorted by or indexed on the START variable.
Tip: MIX requires the least space for output.
Featured in: Example 4 on page 127
SEPARATE
produces a separate page for each value of the CALID variable.
Restriction: The input data must be sorted by the CALID variable and then by the START variable or must contain an appropriate composite index.
Featured in: Example 3 on page 122 and Example 8 on page 148
Default: COMBINE
Specifies the variable that contains the duration of each activity.
Alias: DURATION
Calendar type: Schedule
Interaction: If you use both a DUR and a FIN statement, then DUR is ignored.
Tip: To produce a schedule calendar, you must use either a DUR or FIN statement.
Featured in: All schedule calendars (see Examples: CALENDAR Procedure on page 114)
DUR variable ;
variable
contains the duration of each activity in a schedule calendar.
Range: The duration may be a real or integral value.
Restriction: This variable must be in the activities data set.
See also: For more information on activity durations, see Activities Data Set on page 107 and Calendar Data Set on page 109
Duration is measured inclusively from the start of the activity (as given in the START variable). In the output, any activity that lasts part of a day is displayed as lasting a full day.
The INTERVAL= option in a PROC CALENDAR statement automatically sets the unit of the duration variable, depending on its own value as follows:
If INTERVAL= | Then the default length of the duration unit is |
---|---|
DAY (the default) | 24 hours |
WORKDAY | 8 hours |
You can override the default length of a duration unit by using
the DAYLENGTH= option
a D_LENGTH variable in the CALEDATA= data set.
Specifies the variable in the activities data set that contains the finishing date of each activity.
Alias: FINISH
Calendar type: Schedule
Interaction: If you use both a FIN and a DUR statement, then FIN is used.
Tip: To produce a schedule calendar, you must use either a FIN or DUR statement.
Featured in: Example 6 on page 137
FIN variable ;
variable
contains the finishing date of each activity.
Restriction: The values of variable must be either SAS date or datetime values.
Restriction: If the FIN variable contains datetime values, then you must specify the DATETIME option in the PROC CALENDAR statement.
Restriction: Both the START and FIN variables must have matching formats. For example, if one contains datetime values, then so must the other.
Specifies the variable in the holidays data set that contains the duration of each holiday for a schedule calendar.
Alias: HOLIDURATION
Calendar type: Schedule
Default: If you do not use a HOLIDUR or HOLIFIN statement, then all holidays last
one day.
Restriction: Cannot use with a HOLIFIN statement.
Featured in: Example 1 on page 114 through Example 5 on page 134
HOLIDUR variable ;
variable
contains the duration of each holiday.
Range: The duration may be a real or integral value.
Restriction: This variable must be in the holidays data set.
Featured in: Example 3 on page 122 and Example 8 on page 148
If you use both the HOLIFIN and HOLIDUR statements, then PROC CALENDAR uses the HOLIFIN variable value to define each holiday s duration.
Set the unit of the holiday duration variable in the same way that you set the unit of the duration variable; use either the INTERVAL= and DAYLENGTH= options or the CALEDATA= data set.
Duration is measured inclusively from the start of the holiday (as given in the HOLISTART variable). In the output, any holiday lasting at least half a day appears as lasting a full day.
Specifies the variable in the holidays data set that contains the finishing date of each holiday.
Alias: HOLIFINISH
Calendar type: Schedule
Default: If you do not use a HOLIFIN or HOLIDUR statement, then all holidays last
one day.
HOLIFIN variable ;
variable
contains the finishing date of each holiday.
Restriction: This variable must be in the holidays data set.
Restriction: Values of variable must be in either SAS date or datetime values.
Restriction: If the HOLIFIN variable contains datetime values, then you must specify the DATETIME option in the PROC CALENDAR statement.
If you use both the HOLIFIN and the HOLIDUR statements, then PROC CALENDAR uses only the HOLIFIN variable.
Specifies a variable in the holidays data set that contains the starting date of each holiday.
Alias: HOLISTA, HOLIDAY
Calendar type: Summary and schedule
Requirement: When you use a holidays data set, HOLISTART is required.
Featured in: Example 1 on page 114 through Example 5 on page 134
HOLISTART variable ;
variable
contains the starting date of each holiday.
Restriction: Values of variable must be in either SAS date or datetime values.
Restriction: If the HOLISTART variable contains datetime values, then specify the DATETIME option in the PROC CALENDAR statement.
The holidays data set need not be sorted.
All holidays last only one day, unless you use a HOLIFIN or HOLIDUR statement.
If two or more holidays occur on the same day, then PROC CALENDAR uses only the first observation.
Specifies a variable in the holidays data set whose values are used to label the holidays.
Alias: HOLIVARIABLE, HOLINAME
Calendar type: Summary and schedule
Default: If you do not use a HOLIVAR statement, then PROC CALENDAR uses the word DATE to identify holidays.
Featured in: Example 1 on page 114 through Example 5 on page 134
HOLIVAR variable ;
variable
a variable whose values are used to label the holidays. Typically, this variable contains the names of the holidays.
Range: character or numeric.
Restriction: This variable must be in the holidays data set.
Tip: You can format the HOLIVAR variable as you like.
Specifies numeric variables in the activities data set for which mean values are to be calculated for each month.
Calendar type: Summary
Tip: You can use multiple MEAN statements.
Featured in: Example 7 on page 143
MEAN variable(s) </ FORMAT= format-name >;
variable(s)
numeric variable for which mean values are calculated for each month.
Restriction: This variable must be in the activities data set.
FORMAT= format-name
names a SAS or user-defined format to be used in displaying the means requested .
Alias: F=
Default: BEST. format
Featured in: Example 7 on page 143
The means appear at the bottom of the summary calendar page, if there is room; otherwise they appear on the following page.
The means appear in the LEGEND box if you specify the LEGEND option.
PROC CALENDAR automatically displays variables named in a MEAN statement in the calendar output, even if the variables are not named in the VAR statement.
Specifies in days the length of the week to be displayed.
Alias: OUTDURATION
Requirement: The OUTSTART statement is required.
OUTDUR number-of-days ;
number-of-days
an integer that expresses the length in days of the week to be displayed.
Use either the OUTDUR or OUTFIN statement to supply the procedure with information about the length of the week to display. If you use both, then PROC CALENDAR ignores the OUTDUR statement.
Specifies the last day of the week to display in the calendar.
Alias: OUTFINISH
Requirement: The OUTSTART statement is required.
Featured in: Example 3 on page 122 and Example 8 on page 148
OUTFIN day-of-week ;
day-of-week
the name of the last day of the week to display. For example,
outfin friday;
Use either the OUTFIN or OUTDUR statement to supply the procedure with information about the length of the week to display. If you use both, then PROC CALENDAR uses only the OUTFIN statement.
Specifies the starting day of the week to display in the calendar.
Alias: OUTSTA
Default: If you do not use OUTSTART, then each calendar week begins with Sunday.
Featured in: Example 3 on page 122 and Example 8 on page 148
OUTSTART day-of-week ;
day-of-week
the name of the starting day of the week for each week in the calendar. For example,
outstart monday;
By default, a calendar displays all seven days in a week. Use OUTDUR or OUTFIN, in conjunction with OUTSTART, to control how many days are displayed and which day starts the week.
Specifies the variable in the activities data set that contains the starting date of each activity.
Alias: STA, DATE, ID
Required: START is required for both summary and schedule calendars.
Featured in: All examples
START variable ;
variable
contains the starting date of each activity.
Restriction: This variable must be in the activities data set.
Restriction: Values of variable must be in either SAS date or datetime values.
Restriction: If you use datetime values, then specify the DATETIME option in the PROC CALENDAR statement.
Restriction: Both the START and FIN variables must have matching formats. For example, if one contains datetime values, then so must the other.
Specifies numeric variables in the activities data set to total for each month.
Calendar type: Summary
Tip: To apply different formats to variables that are being summed, use multiple SUM statements.
Featured in: Example 7 on page 143 and Example 8 on page 148
SUM variable(s) </ FORMAT= format-name >;
variable(s)
specifies one or more numeric variables to total for each month.
Restriction: This variable must be in the activities data set.
FORMAT= format-name
names a SAS or user-defined format to use in displaying the sums requested.
Alias: F=
Default: BEST. format
Featured in: Example 7 on page 143 and Example 8 on page 148
The sum appears at the bottom of the calendar page, if there is room; otherwise, it appears on the following page.
The sum appears in the LEGEND box if you specify the LEGEND option.
PROC CALENDAR automatically displays variables named in a SUM statement in the calendar output, even if the variables are not named in the VAR statement.
Specifies the variables that you want to display for each activity.
Alias: VARIABLE
VAR variable(s) ;
variable(s)
specifies one or more variables that you want to display in the calendar.
Range: The values of variable can be either character or numeric.
Restriction: These variables must be in the activities data set.
Tip: You can apply a format to this variable.
If you do not use a VAR statement, then the procedure displays all variables in the activities data set in the order in which they occur in the data set, except for the BY, CALID, START, DUR, and FIN variables. However, not all variables are displayed if the LINESIZE= and PAGESIZE= settings do not allow enough space in the calendar.
PROC CALENDAR displays variables in the order that they appear in the VAR statement. Not all variables are displayed, however, if the LINESIZE= and PAGESIZE= settings do not allow enough space in the calendar.
PROC CALENDAR also displays any variable named in a SUM or MEAN statement for each activity in the calendar output, even if you do not name that variable in a VAR statement.