Concepts: CALENDAR Procedure


Type of Calendars

PROC CALENDAR can produce two kinds of calendars: schedule and summary.

Use a

if you want to

and can accept this restriction

schedule calendar

schedule activities around holidays and nonwork periods

cannot calculate sums and means

schedule calendar

schedule activities that last more than one day

 

summary calendar

calculate sums and means

activities can last only one day

Note: PROC CALENDAR produces a summary calendar if you do not use a DUR or FIN statement in the PROC step.

Schedule Calendar

Definition

A report in calendar format that shows when activities and holidays start and end.

Required Statements

You must supply a START statement and either a DUR or FIN statement.

Use this statement

to specify a variable whose value indicates the

START

starting date of an activity

DUR [*]

duration of an activity

FIN [*]

ending date of an activity

[*] Choose one of these. If you do not use a DUR or FIN statement, then PROC CALENDAR assumes that you want to create a summary calendar report.

[*] Choose one of these. If you do not use a DUR or FIN statement, then PROC CALENDAR assumes that you want to create a summary calendar report.

Examples

See Simple Schedule Calendar on page 79, Advanced Schedule Calendar on page 80, as well as Example 1 on page 114, Example 2 on page 118, Example 3 on page 122, Example 4 on page 127, Example 5 on page 134, and Example 6 on page 137

Summary Calendar

Definition

A report in calendar format that displays activities and holidays that last only one day and that can provide summary information in the form of sums and means.

Required Statements

You must supply a START statement. This statement identifies the variable in the activities data set that contains an activity s starting date.

Multiple Events on a Single Day

A summary calendar report can display only one activity on a given date. Therefore, if more than one activity has the same START value, then only the last observation that was read is used. In such situations, you might find PROC SUMMARY useful in collapsing your data set to contain one activity per starting date.

Examples

See Simple Summary Calendar on page 81, Example 7 on page 143, and Example 8 on page 148

The Default Calendars

Description

PROC CALENDAR provides two default calendars for simple applications. You can produce calendars without having to specify detailed workshifts and weekly work patterns if your application can use one of two simple work patterns. Consider using a default calendar if

  • your application uses a 5-day work week with 8-hour days or a 7-day work week with 24- hour days. See Table 5.2 on page 104.

    Table 5.2: Default Calendar Settings and Examples

    If scheduled work days are

    Then set INTERVAL=

    By default DAYLENGTH=

    So work periods are

    Shown in Example

    7 (M-Sun)

    DAY

    24

    24-hour days

    2

    5 (M-F)

    WORKDAY

    8

    8-hour days

    1

  • you want to print all activities on the same calendar.

  • you do not need to identify separate calendars.

When You Unexpectedly Produce a Default Calendar

If you want to produce a specialized calendar but do not provide all the necessary information, then PROC CALENDAR attempts to produce a default calendar. These errors cause PROC CALENDAR to produce a calendar with default features:

  • If the activities data set does not contain a CALID variable, then PROC CALENDAR produces a default calendar.

  • If both the holidays and calendar data sets do not contain a CALID variable, then PROC CALENDAR produces a default calendar even if the activities data set contains a CALID variable .

  • If the activities and calendar data sets contain the CALID variable, but the holidays data set does not, then the default holidays are used.

Examples

See the 7-day default calendar in Output 5.1 and the 5-day default calendar in Example 1 on page 114

Calendars and Multiple Calendars

Definitions

calendar

  • a logical entity that represents a weekly work pattern, which consists of weekly work schedules and daily shifts. PROC CALENDAR contains two default work patterns: 5-day week with an 8-hour day or a 7-day week with a 24-hour day. You can also define your own work patterns by using CALENDAR and WORKDAYS data sets.

calendar report

  • a report in calendar format that displays activities, holidays, and nonwork periods.

  • A calendar report can contain multiple calendars in one of three formats

    • separate

      • Each identified calendar prints on separate output pages.

    • combined

      • All identified calendars print on the same output pages and each is identified.

    • mixed

      • All identified calendars print on the same output pages but are not identified as belonging to separate calendars.

    • multiple calendar

      • a logical entity that represents multiple weekly work patterns.

Why Create Multiple Calendars

Create a multiple calendar if you want to print a calendar report that shows activities that follow different work schedules or different weekly work patterns. For example, a construction project report might need to use different work schedules and weekly work patterns for work crews on different parts of the project.

Another use for multiple calendars is to identify activities so that you can choose to print them in the same calendar report. For example, if you identify activities as belonging to separate departments within a division, then you can choose to print a calendar report that shows all departmental activities on the same calendar.

Finally, using multiple calendars, you can produce separate calendar reports for each calendar in a single step. For example, if activities are identified by department, then you can produce a calendar report that prints the activities of each department on separate pages.

How to Identify Multiple Calendars

Because PROC CALENDAR can process only one data set of each type (activities, holidays, calendar, workdays) in a single PROC step, you must be able to identify for PROC CALENDAR which calendar an activity, holiday, or weekly work pattern belongs to. Use the CALID statement to specify the variable whose values identify the appropriate calendar. This variable can be numeric or character.

You can use the special variable name _CAL_ or you can use another variable name. PROC CALENDAR automatically looks for a variable named _CAL_ in the holiday and calendar data sets, even when the activities data set uses a variable with another name as the CALID variable. Therefore, if you use the name _CAL_ in your holiday and calendar data sets, then you can more easily reuse these data sets in different calendar applications.

Using Holidays or Calendar Data Sets with Multiple Calendars

When using a holidays or calendar data set with multiple calendars, PROC CALENDAR treats the variable values in the following way:

  • Every value of the CALID variable that appears in either the holidays or calendar data sets defines a calendar.

  • If a CALID value appears in the HOLIDATA= data set but not in the CALEDATA= data set, then the work schedule of the default calendar is used.

  • If a CALID value appears in the CALEDATA= data set but not in the HOLIDATA= data set, then the holidays of the default calendar are used.

  • If a CALID value does not appear in either the HOLIDATA= or CALEDATA= data set, then the work schedule and holidays of the default calendar are used.

  • If the CALID variable is not found in the holiday or calendar data set, then PROC CALENDAR looks for the default variable _CAL_ instead. If neither the CALID variable nor a _CAL_ variable appears in a data set, then the observations in that data set are applied to a default calendar.

Types of Reports That Contain Multiple Calendars

Because you can associate different observations with different calendars, you can print a calendar report that shows activities that follow different work schedules or different work shifts or that contain different holidays. You can

  • print separate calendars on the same page and identify each one.

  • print separate calendars on the same page without identifying them.

  • print separate pages for each identified calendar.

As an example, consider a calendar that shows the activities of all departments within a division. Each department can have its own calendar identification value and, if necessary, can have individual weekly work patterns, daily work shifts, and holidays.

If you place activities that are associated with different calendars in the same activities data sets, then you use PROC CALENDAR to produce calendar reports that print

  • the schedule and events for each department on a separate pages (separate output)

  • the schedule and events for the entire division, each identified by department (combined output)

  • the schedule and events for the entire division, but not identified by department (mixed output).

The multiple-calendar feature was added specifically to enable PROC CALENDAR to process the output of PROC CPM in SAS/OR software, a project management tool. See Example 6 on page 137.

How to Identify Calendars with the CALID Statement and the Special Variable _CAL_

To identify multiple calendars, you must use the CALID statement to specify the variable whose values identify which calendar an event belongs with. This variable can be numeric or character.

You can use the special variable name _CAL_ or you can use another variable name. PROC CALENDAR automatically looks for a variable named _CAL_ in the holiday and calendar data sets, even when the activities data set uses a variable with another name as the CALID variable. Therefore, if you use the name _CAL_ in your holiday and calendar data sets, then you can more easily reuse these data sets in different calendar applications.

When You Use Holidays or Calendar Data Sets

When you use a holidays or calendar data set with multiple calendars, PROC CALENDAR treats the variable values in the following way:

  • Every value of the CALID variable that appears in either the holidays or calendar data sets defines a calendar.

  • If a CALID value appears in the HOLIDATA= data set but not in the CALEDATA= data set, then the work schedule of the default calendar is used.

  • If a CALID value appears in the CALEDATA= data set but not in the HOLIDATA= data set, then the holidays of the default calendar are used.

  • If a CALID value does not appear in either the HOLIDATA= or CALEDATA= data set, then the work schedule and holidays of the default calendar are used.

  • If the CALID variable is not found in the holiday or calendar data sets, then PROC CALENDAR looks for the default variable _CAL_ instead. If neither the CALID variable nor a _CAL_ variable appears in a data set, then the observations in that data set are applied to a default calendar.

Examples

Example 2 on page 118, Example 3 on page 122, Example 4 on page 127, and Example 8 on page 148

Input Data Sets

You may need several data sets to produce a calendar, depending on the complexity of your application. PROC CALENDAR can process one of each of four data sets. See Table 5.3 on page 107.

Table 5.3: Four Possible Input Data Sets for PROC CALENDAR

Data Set

Description

Specify with the

activities

Each observation contains information about a single activity.

DATA= option

holidays

Each observation contains information about a holiday

HOLIDATA= option

calendar

Each observation defines one weekly work schedule.

CALEDATA= option

workdays

Each variable represents one daily schedule of alternating work and nonwork periods.

WORKDATA= option

Activities Data Set

Purpose

The activities data set, specified with the DATA= option, contains information about the activities to be scheduled by PROC CALENDAR. Each observation describes a single activity.

Requirements and Restrictions

  • An activities data set is required. (If you do not specify an activities data set with the DATA= option, then PROC CALENDAR uses the _LAST_ data set.)

  • Only one activities data set is allowed.

  • The activities data set must always be sorted or indexed by the START variable.

  • If you use a CALID (calendar identifier) variable and want to produce output that shows multiple calendars on separate pages, then the activities data set must be sorted by or indexed on the CALID variable and then the START variable.

  • If you use a BY statement, then the activities data set must be sorted by or indexed on the BY variables .

Structure

Each observation in the activities data set contains information about one activity. One variable must contain the starting date. If you are producing a schedule calendar, then another variable must contain either the activity duration or finishing date. Other variables can contain additional information about an activity.

If a variable contains an activity s

Then specify it with the

For this type of calendar

starting date

START statement

Schedule

   

Summary

duration

DUR statement

Schedule

finishing date

FIN statement

Schedule

Multiple Activities per Day in Summary Calendars

A summary calendar can display only one activity on a given date. Therefore, if more than one activity has the same START value, then only the last observation that is read is used. In such situations, you might find PROC SUMMARY useful to collapse your data set to contain one activity per starting date.

Examples

Every example in the Examples section uses an activities data set.

Holidays Data Set

Purpose

You can use a holidays data set, specified with the HOLIDATA= option, to

  • identify holidays on your calendar output

  • identify days that are not available for scheduling work. (In a schedule calendar, PROC CALENDAR does not schedule activities on these days.)

Structure

Each observation in the holidays data set must contain at least the holiday starting date. A holiday lasts only one day unless a duration or finishing date is specified. Supplying a holiday name is recommended, though not required. If you do not specify which variable contains the holiday name, then PROC CALENDAR uses the word DATE to identify each holiday.

If a variable contains a holiday s

Then specify it with this statement

starting date

HOLISTART

name

HOLIVAR

duration

HOLIDUR

finishing date

HOLIFIN

No Sorting Needed

You do not need to sort or index the holidays data set.

Using SAS Date Versus SAS Datetime Values

PROC CALENDAR calculates time using SAS datetime values. Even when your data is in DATE. format, the procedure automatically calculates time in minutes and seconds. Therefore, if you specify only date values, then PROC CALENDAR prints messages similar to the following ones to the SAS log:

 NOTE: All holidays are assumed to start at the        time/date specified for the holiday variable        and last one DTWRKDAY.  WARNING: The units of calculation are SAS datetime           values while all the holiday variables are           not. All holidays are converted to SAS           datetime values. 

Create a Generic Holidays Data Set

If you have many applications that require PROC CALENDAR output, then consider creating a generic holidays data set that contains standard holidays. You can begin with the generic holidays and add observations that contain holidays or nonwork events specific to an application.

Holidays and Nonwork Periods

Do not schedule holidays during nonwork periods. Holidays that are defined in the HOLIDATA= data set cannot occur during any nonwork periods that are defined in the work schedule. For example, you cannot schedule Sunday as a vacation day if the work week is defined as Monday through Friday. When such a conflict occurs, the holiday is rescheduled to the next available working period following the nonwork day.

Examples

Every example in the Examples section uses a holidays data set.

Calendar Data Set

Purpose

You can use a calendar data set, specified with the CALEDATA= option, to specify work schedules for different calendars.

Structure

Each observation in the calendar data set defines one weekly work schedule. The data set created in the DATA step shown below defines weekly work schedules for two calendars, CALONE and CALTWO.

 data cale;     input _sun_ $ _mon_ $ _tue_ $ _wed_ $ _thu_ $ /           _fri_ $ _sat_ $ _cal_ $ d_length time6.;     datalines;  holiday workday workday workday workday  workday holiday calone 8:00  holiday shift1 shift1 shift1 shift1  shift2 holiday caltwo 9:00  ; 

The variables in this calendar data set consist of

_SUN_ through _SAT_

  • the name of each day of the week that appears in the calendar. The values of these variables contain the name of workshifts. Valid values for workshifts are

    • WORKDAY (the default workshift)

    • HOLIDAY (a nonwork period)

    • names of variables in the WORKDATA= data set (in this example, SHIFT1 and SHIFT2 ).

_CAL_

  • the CALID (calendar identifier) variable. The values of this variable identify different calendars. If this variable is not present, then the first observation in this data set defines the work schedule that is applied to all calendars in the activities data set.

    If the CALID variable contains a missing value, then the character or numeric value for the default calendar ( DEFAULT or 0) is used. See The Default Calendars on page 103 for further details.

D_LENGTH

  • the daylength identifier variable. Values of D_LENGTH indicate the length of the standard workday to be used in calendar calculations. You can set the workday length either by placing this variable in your calendar data set or by using the DAYLENGTH= option.

    Missing values for this variable default to the number of hours specified in the DAYLENGTH= option; if the DAYLENGTH= option is not used, the day length defaults to 24 hours if INTERVAL=DAY, or 8 hours if INTERVAL=WORKDAY.

Using Default Workshifts Instead of a Workdays Data Set

You can use a calendar data set with or without a workdays data set. Without a workdays data set, WORKDAY in the calendar data set is equal to one of two standard workdays, depending on the setting of the INTERVAL= option:

If INTERVAL=

Then the work-shift begins at

And the day length is

DAY

00:00

24 hours

WORKDAY

9:00

8 hours

You can reset the length of the standard workday with the DAYLENGTH= option or a D_LENGTH variable in the calendar data set. You can define other work shifts in a workdays data set.

Examples

Example 3 on page 122, Example 4 on page 127, and Example 7 on page 143 feature a calendar data set.

Workdays Data Set

Purpose

You can use a workdays data set, specified with the WORKDATA= option, to define the daily workshifts named in a CALEDATA= data set.

Use Default Work Shifts or Create Your Own?

You do not need a workdays data set if your application can use one of two default work shifts:

If INTERVAL=

Then the work-shift begins at

And the day length is

DAY

00:00

24 hours

WORKDAY

9:00

8 hours

See the INTERVAL= option on page 90.

Structure

Each variable in the workdays data set contains one daily schedule of alternating work and nonwork periods. For example, this DATA step creates a data set that contains specifications for two work shifts:

 data work;     input shift1  time6. shift2 time6.;     datalines;  7:00  7:00  12:00 11:00  13:00   .  17:00   .  ; 

The variable SHIFT1 specifies a 10-hour workday, with one nonwork period (a lunch hour); the variable SHIFT2 specifies a 4-hour workday with no nonwork periods.

How Missing Values Are Treated

The missing values default to 00:00 in the first observation and to 24:00 in all other observations. Two consecutive values of 24:00 define a zero-length time period, which is ignored.

Examples

See Example 3 on page 122

Missing Values in Input Data Sets

Table 5.4 on page 112 summarizes the treatment of missing values for variables in the data sets used by PROC CALENDAR.

Table 5.4: Treatment of Missing Values in PROC CALENDAR

Data set

Variable

Treatment of missing values

Activities (DATA=)

CALID

default calendar value is used

START

observation is not used

DUR

1.0 is used

FIN

START value + daylength is used

VAR

if a summary calendar or the MISSING option is specified, then the missing value is used; otherwise , no value is used

SUM, MEAN

Calendar (CALEDATA=)

CALID

default calendar value is used

_SUN_ through _SAT_

corresponding shift for default calendar is used

D_LENGTH

if available, DAYLENGTH= value is used; otherwise, if INTERVAL=DAY, 24:00 is used; otherwise 8:00 is used

SUM, MEAN

Holiday (HOLIDATA=)

CALID

all holidays apply to all calendars

HOLISTART

observation is not used

HOLIDUR

if available, HOLIFIN value is used instead of HOLIDUR value; otherwise 1.0 is used

HOLIFIN

if available, HOLIDUR value is used instead of HOLIFIN value; otherwise, HOLISTART value + day length is used

HOLIVAR

no value is used

Workdays (WORKDATA=)

any

for the first observation, 00:00 is used; otherwise, 24:00 is used




Base SAS 9.1.3 Procedures Guide (Vol. 1)
Base SAS 9.1 Procedures Guide, Volumes 1, 2, 3 and 4
ISBN: 1590472047
EAN: 2147483647
Year: 2004
Pages: 260

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net