Examples: CALENDAR Procedure


Example 1: Schedule Calendar with Holidays: 5-Day Default

Procedure features:

  • PROC CALENDAR statement options:

    • DATA=

    • HOLIDATA=

    • WEEKDAYS

  • DUR statement

  • HOLISTART statement

  • HOLIVAR statement

  • HOLIDUR statement

  • START statement

Other features:

  • PROC SORT statement

  • BY statement

  • 5-day default calendar

This example

  • creates a schedule calendar

  • uses one of the two default work patterns: 8- hour day, 5-day week

  • schedules activities around holidays

  • displays a 5-day week

Program

Create the activities data set. ALLACTY contains both personal and business activities information for a bank president.

 data allacty;     input date : date7. event $ 9-36 who $ 37-48 long;     datalines;  01JUL96 Dist. Mtg.                  All          1  17JUL96 Bank Meeting                1st Natl     1  02JUL96 Mgrs. Meeting               District 6   2  11JUL96 Mgrs. Meeting               District 7   2  03JUL96 Interview                   JW           1  08JUL96 Sales Drive                 District 6   5  15JUL96 Sales Drive                 District 7   5  08JUL96 Trade Show                  Knox         3  22JUL96 Inventors Show              Melvin       3  11JUL96 Planning Council            Group II     1  18JUL96 Planning Council            Group III    1  25JUL96 Planning Council            Group IV     1  12JUL96 Seminar                     White        1  19JUL96 Seminar                     White        1  18JUL96 NewsLetter Deadline         All          1  05JUL96 VIP Banquet                 JW           1  19JUL96 Co. Picnic                  All          1  16JUL96 Dentist                     JW           1  24JUL96 Birthday                    Mary         1  25JUL96 Close Sale                  WYGIX Co.    2  ; 

Create the holidays data set.

 data hol;     input date : date7. holiday $ 11-25 holilong @27;     datalines;  05jul96   Vacation        3  04jul96   Independence    1  ; 

Sort the activities data set by the variable that contains the starting date. You are not required to sort the holidays data set.

 proc sort data=allacty;     by date;  run; 

Set LINESIZE=appropriately. If the line size is not long enough to print the variable values, then PROC CALENDAR either truncates the values or produces no calendar output.

 options nodate pageno=1 linesize=132 pagesize=60; 

Create the schedule calendar. DATA=identifies the activities data set; HOLIDATA= identifies the holidays data set. WEEKDAYS specifies that a week consists of five eight-hour work days.

 proc calendar data=allacty holidata=hol weekdays; 

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, HOLIVAR, and HOLIDUR statements specify the variables in the holidays data set that contain the start date, name , and duration of each holiday, respectively. When you use a holidays data set, HOLISTART is required. Because at least one holiday lasts more than one day, HOLIDUR is required.

 holistart date;  holivar holiday;  holidur holilong; 

Specify the titles.

 title1 'Summer Planning Calendar:  Julia Cho';     title2 'President, Community Bank';  run; 

Output

Output 5.4: Schedule Calendar: 5-Day Week with Holidays
start example
 Summer Planning Calendar:   Julia Cho                                             1                                                        President, Community Bank  -----------------------------------------------------------------------------------------------------------------------------------                                                                                                                                                                                                July   1996                                                                                                                                                                                               ---------------------------------------------------------------------------------------------------------------------------------           Monday                   Tuesday                 Wednesday                Thursday                  Friday            -------------------------+-------------------------+-------------------------+-------------------------+-------------------------              1                        2                         3                        4                       5                                                                                         ******Independence***************Vacation*********                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                +=====Interview/JW======+                                                    +====Dist. Mtg./All=====++============Mgrs. Meeting/District 6=============+                                                    -------------------------+-------------------------+-------------------------+-------------------------+-------------------------              8                        9                        10                       11                      12              ********Vacation*****************Vacation*********                                                                                                                                                                                                                                                                                                                                                                                                                      +Planning Council/Group ++=====Seminar/White=====+                                                    +==============================Trade Show/Knox==============================+                                                    +==========================Sales Drive/District 6===========================>                                                    +====VIP Banquet/JW=====++============Mgrs. Meeting/District 7=============+  -------------------------+-------------------------+-------------------------+-------------------------+-------------------------              15                      16                        17                       18                      19                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   +======Dentist/JW=======+                         +NewsLetter Deadline/All++====Co. Picnic/All=====+  +====================================================Sales Drive/District 7=====================================================+  <=============Sales Drive/District 6==============++=Bank Meeting/1st Natl=++Planning Council/Group ++=====Seminar/White=====+  -------------------------+-------------------------+-------------------------+-------------------------+-------------------------              22                      23                        24                       25                      26                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           +=====Birthday/Mary=====++==============Close Sale/WYGIX Co.===============+  +===========================Inventors Show/Melvin===========================++Planning Council/Group +                           -------------------------+-------------------------+-------------------------+-------------------------+-------------------------              29                      30                        31                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        ----------------------------------------------------------------------------------------------------------------------------------- 
end example
 

Example 2: Schedule Calendar Containing Multiple Calendars

Procedure features:

  • CALID statement:

    • _CAL_ variable

    • OUTPUT=COMBINE option

  • DUR statement

  • 24-hour day, 7-day week

This example builds on Example 1 by identifying activities as belonging to one of two calendars, business or personal. This example

  • 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

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;  01JUL96  Dist. Mtg.               All          CAL1   1  02JUL96  Mgrs. Meeting            District 6   CAL1   2  03JUL96  Interview                JW           CAL1   1  05JUL96  VIP Banquet              JW           CAL1   1  06JUL96  Beach trip               family       CAL2   2  08JUL96  Sales Drive              District 6   CAL1   5  08JUL96  Trade Show               Knox         CAL1   3  09JUL96  Orthodontist             Meagan       CAL2   1  11JUL96  Mgrs. Meeting            District 7   CAL1   2  11JUL96  Planning Council         Group II     CAL1   1  12JUL96  Seminar                  White        CAL1   1  14JUL96  Co. Picnic               All          CAL1   1  14JUL96  Business trip            Fred         CAL2   2  15JUL96  Sales Drive              District 7   CAL1   5  16JUL96  Dentist                  JW           CAL1   1  17JUL96  Bank Meeting             1st Natl     CAL1   1  17JUL96  Real estate agent        Family       CAL2   1  18JUL96  NewsLetter Deadline      All          CAL1   1  18JUL96  Planning Council         Group III    CAL1   1  19JUL96  Seminar                  White        CAL1   1  22JUL96  Inventors Show           Melvin       CAL1   3  24JUL96  Birthday                 Mary         CAL1   1  25JUL96  Planning Council         Group IV     CAL1   1  25JUL96  Close Sale               WYGIX Co.    CAL1   2  27JUL96  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;  29JUL96   vacation               CAL2  04JUL96   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 LINESIZE= appropriately. If the linesize is not long enough to print the variable values, then PROC CALENDAR either truncates the values or produces no calendar output.

 options nodate pageno=1 pagesize=60 linesize=132; 

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

Output 5.5: Schedule Calendar Containing Multiple Calendars
start example
 Summer Planning Calendar:  Julia Cho                                         1                                                           President, Community Bank                                                             Work and Home Schedule            ------------------------------------------------------------------------------------------------------------------------                                                                                                                                                                                                   July   1996                                                                                                                                                                                                   ----------------------------------------------------------------------------------------------------------------------                 Sunday          Monday         Tuesday        Wednesday        Thursday         Friday         Saturday      ----------+----------------+----------------+----------------+----------------+----------------+----------------+----------------                                   1               2               3               4               5               6         .........................................................................................................................   CAL2                                                                                                    +Beach trip/fam>  .........................................................................................................................   CAL1                                                    +=Interview/JW=+**Independence**                                                           +Dist. Mtg./All++===Mgrs. Meeting/District 6====+                +VIP Banquet/JW+                                                                                                                                             ---------+----------------+----------------+----------------+----------------+----------------+----------------+----------------                   7               8               9              10              11              12              13         .........................................................................................................................   CAL2    <Beach trip/fam+                +Orthodontist/M+                                                                  .........................................................................................................................   CAL1                                                                    +Planning Counc++Seminar/White=+                                           +================Trade Show/Knox=================++===Mgrs. Meeting/District 7====+                                           +==============================Sales Drive/District 6==============================+                  ---------+----------------+----------------+----------------+----------------+----------------+----------------+----------------                  14               15              16             17               18              19             20         .........................................................................................................................   CAL2    +======Business trip/Fred=======+                +Real estate ag+                                                  .........................................................................................................................   CAL1                                                                    +Planning Counc+                                                                           +==Dentist/JW==++Bank Meeting/1++NewsLetter Dea++Seminar/White=+                           +Co. Picnic/All++==============================Sales Drive/District 7==============================+                  ---------+----------------+----------------+----------------+----------------+----------------+----------------+----------------                  21               22              23             24               25              26             27         .........................................................................................................................   CAL2                                                                                                    +Ballgame/Famil+  .........................................................................................................................   CAL1                                                    +Birthday/Mary=++=====Close Sale/WYGIX Co.======+                                           +=============Inventors Show/Melvin==============++Planning Counc+                                                                                                                                                             ---------+----------------+----------------+----------------+----------------+----------------+----------------+----------------                  28               29              30             31                                                         .........................................................................................................................   CAL2                    ****vacation****                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              ---------------------------------------------------------------------------------------------------------------------------------- 
end example
 

Example 3: Multiple Schedule Calendars with Atypical Workshifts (Separated Output)

Procedure features:

  • PROC CALENDAR statement options:

    • CALEDATA=

    • DATETIME

    • WORKDATA=

  • CALID statement:

    • _CAL_ variable

    • OUTPUT=SEPARATE option

  • DUR statement

  • OUTSTART statement

  • OUTFIN statement

This example

  • produces separate output pages for each calendar in a single PROC step

  • schedules activities around holidays

  • displays an 8-hour day, 5 1/2-day week

  • uses separate work patterns and holidays for each calendar.

Producing Different Output for Multiple Calendars

This example and Example 4 on page 127 use the same input data for multiple calendars to produce different output. The only differences in these programs are how the activities data set is sorted and how the OUTPUT= option is set.

To print

Sort the activities data set by

And set OUTPUT= to

See Example

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

Specify a library so that you can permanently store the activities data set.

 libname well '  SAS-data-library  '; 

Create the activities data set and identify separate calendars. WELL.ACT is a permanent SAS data set that contains activities for a well construction project. The _CAL_ variable identifies the calendar that an activity belongs to.

 data well.act;     input task & . dur : 5. date : datetime16. _cal_ $ cost;     datalines;  Drill Well          3.50  01JUL96:12:00:00  CAL1  1000  Lay Power Line      3.00  04JUL96:12:00:00  CAL1  2000  Assemble Tank       4.00  05JUL96:08:00:00  CAL1  1000  Build Pump House    3.00  08JUL96:12:00:00  CAL1  2000  Pour Foundation     4.00  11JUL96:08:00:00  CAL1  1500  Install Pump        4.00  15JUL96:14:00:00  CAL1   500  Install Pipe        2.00  19JUL96:08:00:00  CAL1  1000  Erect Tower         6.00  20JUL96:08:00:00  CAL1  2500  Deliver Material    2.00  01JUL96:12:00:00  CAL2   500  Excavate            4.75  03JUL96:08:00:00  CAL2  3500  ; 

Create the holidays data set. The _CAL_ variable identifies the calendar that a holiday belongs to.

 data well.hol;     input date date. holiday $ 11-25 _cal_ $;     datalines;  09JUL96   Vacation            CAL2  04JUL96   Independence        CAL1  ; 

Create the calendar data set. Each observation defines the workshifts for an entire week. The _CAL_ variable identifies to which calendar the workshifts apply. CAL1 uses the default 8-hour workshifts for Monday through Friday. CAL2 uses a half day on Saturday and the default 8-hour workshift for Monday through Friday.

 data well.cal;     input _sun_ $ _sat_ $ _mon_ $ _tue_ $ _wed_ $ _thu_ $           _fri_ $ _cal_ $;     datalines;  Holiday Holiday  Workday Workday Workday Workday Workday CAL1  Holiday Halfday  Workday Workday Workday Workday Workday CAL2  ; 

Create the workdays data set. This data set defines the daily workshifts that are named in the calendar data set. Each variable (not observation) contains one daily schedule of alternating work and nonwork periods. The HALFDAY workshift lasts 4 hours.

 data well.wor;     input halfday time5.;     datalines;  08:00  12:00  ; 

Sort the activities data set by the variables that contain the calendar identification and the starting date, respectively. You are not required to sort the holidays data set.

 proc sort data=well.act;     by _cal_ date;  run; 

Set LINESIZE= appropriately. If the linesize is not long enough to print the variable values, then PROC CALENDAR either truncates the values or produces no calendar output.

 options nodate pageno=1 linesize=132 pagesize=60; 

Create the schedule calendar. DATA= identifies the activities data set; HOLIDATA= identifies the holidays data set; CALEDATA= identifies the calendar data set; WORKDATA= identifies the workdays data set. DATETIME specifies that the variable specified with the START statement contains values in SAS datetime format.

 proc calendar data=well.act                holidata=well.hol                caledata=well.cal                workdata=well.wor                datetime; 

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 an activity duration variable. The START statement specifies the variable in the activities data set that contains the activity starting date; DUR specifies the variable that contains the activity duration. START and DUR are required for a schedule calendar.

 start date;  dur dur; 

Retrieve holiday information. HOLISTART and HOLIVAR 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 date;  holivar holiday; 

Customize the calendar appearance. OUTSTART and OUTFIN specify that the calendar display a 6-day week, Monday through Saturday.

 outstart Monday;  outfin Saturday; 

Specify the title and format the Cost variable.

 title1 'Well Drilling Work Schedule: Separate Calendars';     format cost dollar9.2;  run; 

Output

Output 5.6: Separate Output for Multiple Schedule Calendars
start example
 Well Drilling Work Schedule: Separate Calendars                                          1  ............................................................ _cal_=CAL1 ............................................................    -------------------------------------------------------------------------------------------------------------------------------                                                                                                                                                                                             July  1996                                                                                                                                                                                               -----------------------------------------------------------------------------------------------------------------------------           Monday             Tuesday            Wednesday            Thursday             Friday             Saturday          --------------------+--------------------+--------------------+--------------------+--------------------+--------------------              1                    2                  3                   4                   5                   6                                                                         ****Independence****                                                                                                                                                                                                                                                                                                                                                                                    +Assemble Tank/,0>                                                                                                        +Lay Power Line/,>                        +====================Drill Well/,000.00====================>                    <Drill Well/,000.+                        --------------------+--------------------+--------------------+--------------------+--------------------+--------------------              8                   9                  10                  11                  12                  13                                                                                                                                                                                                                                                                                                                                                                                                 +===========================Build Pump House/,000.00============================+                                            <=============================Assemble Tank/,000.00=============================+                                            <=======Lay Power Line/,000.00========+                    +=======Pour Foundation/,500.00 ======>                        --------------------+--------------------+--------------------+--------------------+--------------------+--------------------             15                  16                  17                  18                  19                  20                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             +=========================================Install Pump/0.00=========================================+                        <=================Pour Foundation/,500.00==================+                    +Install Pipe/,00>                        --------------------+--------------------+--------------------+--------------------+--------------------+--------------------             22                  23                    24                25                  26                   27                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            +========================================Erect Tower/,500.00=========================================>                        <========Install Pipe/,000.00=========+                                                                                    --------------------+--------------------+--------------------+--------------------+--------------------+--------------------             29                  30                    31                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   <Erect Tower/,500+                                                                                                        -------------------------------------------------------------------------------------------------------------------------------                                           Well Drilling Work Schedule: Separate Calendars                                          2  ............................................................ _cal_=CAL2 ............................................................     -------------------------------------------------------------------------------------------------------------------------------                                                                                                                                                                                               July   1996                                                                                                                                                                                                -----------------------------------------------------------------------------------------------------------------------------            Monday             Tuesday            Wednesday            Thursday             Friday             Saturday           --------------------+--------------------+--------------------+--------------------+--------------------+--------------------               1                   2                   3                   4                   5                   6                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          +===============================Excavate/,500.00================================>     +==================Deliver Material/0.00==================+                                                                 --------------------+--------------------+--------------------+--------------------+--------------------+--------------------               8                   9                  10                  11                  12                  13                                  ******Vacation******                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         <Excavate/,500.00>                    <Excavate/,500.00+                                                                 --------------------+--------------------+--------------------+--------------------+--------------------+--------------------              15                  16                  17                  18                  19                  20                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            --------------------+--------------------+--------------------+--------------------+--------------------+--------------------              22                  23                  24                  25                  26                  27                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            --------------------+--------------------+--------------------+--------------------+--------------------+--------------------              29                  30                  31                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        ------------------------------------------------------------------------------------------------------------------------------- 
end example
 

Example 4: Multiple Schedule Calendars with Atypical Workshifts (Combined and Mixed Output)

Procedure features:

  • PROC CALENDAR statement options:

    • CALEDATA=

    • DATETIME

    • WORKDATA=

  • CALID statement:

    • _CAL_ variable

    • OUTPUT=COMBINE option

    • OUTPUT=MIXED option

  • DUR statement

  • OUTSTART statement

  • OUTFIN statement

Data sets:

  • WELL.ACT on page 123, WELL.HOL on page 123, WELL.CAL on page 123, WEL.WOR on page 123.

This example

  • produces a schedule calendar

  • schedules activities around holidays

  • uses separate work patterns and holidays for each calendar

  • uses an 8-hour day, 5 1/2-day work week

  • displays and identifies multiple calendars on each calendar page (combined output)

  • displays but does not identify multiple calendars on each calendar page (mixed output).

Two Programs and Two Pieces of Output

This example creates both combined and mixed output. Producing combined or mixed calendar output requires only one change to a PROC CALENDAR step: the setting of the OUTPUT= option in the CALID statement. Combined output is produced first, then mixed output.

Producing Different Output for Multiple Calendars

This example and Example 3 on page 122 use the same input data for multiple calendars to produce different output. The only differences in these programs are how the activities data set is sorted and how the OUTPUT= option is set.

To print

Sort the activities data set by

And set OUTPUT= to

See Example

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 for Combined Calendars

Specify the SAS data library where the activities data set is stored.

 libname well '  SAS-data-library  '; 

Sort the activities data set by the variable that contains the starting date. Do not sort by the CALID variable when producing combined calendar output.

 proc sort data=well.act;     by date;  run; 

Set PAGESIZE= and LINESIZE= appropriately. When you combine calendars, check the value of PAGESIZE= to ensure that there is enough room to print the activities from multiple calendars. If LINESIZE= is too small for the variable values to print, then PROC CALENDAR either truncates the values or produces no calendar output.

 options nodate pageno=1 linesize=132 pagesize=60; 

Create the schedule calendar. DATA= identifies the activities data set; HOLIDATA= identifies the holidays data set; CALEDATA= identifies the calendar data set; WORKDATA= identifies the workdays data set. DATETIME specifies that the variable specified with the START statement contains values in SAS datetime format.

 proc calendar data=well.act                holidata=well.hol                caledata=well.cal                workdata=well.wor                datetime; 

Combine all events and holidays on a single calendar. The CALID statement specifies that the _CAL_ variable identifies the calendars. OUTPUT=COMBINE prints multiple calendars on the same page and identifies each 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. START and DUR are required for a schedule calendar.

 start date;  dur dur; 

Retrieve holiday information. HOLISTART and HOLIVAR 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 date;  holivar holiday; 

Specify the title and format the Cost variable.

 title1 'Well Drilling Work Schedule: Combined Calendars';     format cost dollar9.2;  run; 

Output for Combined Calendars

Output 5.7: Multiple Schedule Calendars with Atypical Workshifts (Combined Output)
start example
 Well Drilling Work Schedule: Combined Calendars                                          1            ------------------------------------------------------------------------------------------------------------------------                                                                                                                                                                                                   July  1996                                                                                                                                                                                                    ----------------------------------------------------------------------------------------------------------------------                 Sunday          Monday         Tuesday        Wednesday        Thursday         Friday         Saturday      ----------+----------------+----------------+----------------+----------------+----------------+----------------+----------------                                   1               2               3               4               5               6         .........................................................................................................................   CAL1                                                                    **Independence**+Assemble Tank/>                                                                                                           +Lay Power Line>                                           +==============Drill Well/,000.00==============>                <Drill Well/,+                  .........................................................................................................................   CAL2                                                    +=======================Excavate/,500.00========================>  ---------+----------------+----------------+----------------+----------------+----------------+----------------+----------------                   7               8               9              10              11               12             13         .........................................................................................................................   CAL1                    +===================Build Pump House/,000.00====================+                                                           <=====================Assemble Tank/,000.00=====================+                                                           <===Lay Power Line/,000.00====+                +===Pour Foundation/,500.00===>                  .........................................................................................................................   CAL2                    <Excavate/,50>****Vacation****<Excavate/,50+                                                  ---------+----------------+----------------+----------------+----------------+----------------+----------------+----------------                  14              15              16              17              18              19              20         .........................................................................................................................   CAL1                    +===============================Install Pump/0.00===============================+                                           <===========Pour Foundation/,500.00============+                +Install Pipe/$>                                                                                                                                                                                                                                                                                                                                                                                                   ---------+----------------+----------------+----------------+----------------+----------------+----------------+----------------                  21              22              23              24              25              26              27         .........................................................................................................................   CAL1                    +==============================Erect Tower/,500.00===============================>                                           <====Install Pipe/,000.00=====+                                                                                                                                                                                                                                                                                                                                                                                                                                                   ---------+----------------+----------------+----------------+----------------+----------------+----------------+----------------                  28              29              30              31                                                         .........................................................................................................................   CAL1                    <Erect Tower/+                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              ---------------------------------------------------------------------------------------------------------------------------------- 
end example
 

Program for Mixed Calendars

To produce mixed output instead of combined, use the same program and change the setting of the OUTPUT= option to OUTPUT=MIX:

 proc calendar data=well.act                holidata=well.hol                caledata=well.cal                workdata=well.wor                datetime;     calid _cal_ / output=mix;     start date;     dur dur;     holistart date;     holivar holiday;     outstart Monday;     outfin Saturday;     title1 'Well Drilling Work Schedule: Mixed Calendars';     format cost dollar9.2;  run; 

Output for Mixed Calendars

Output 5.8: Multiple Schedule Calendar with Atypical Workshifts (Mixed Output)
start example
 Well Drilling Work Schedule: Mixed Calendars                                           1  ------------------------------------------------------------------------------------------------------------------------------                                                                                                                                                                                         July  1996                                                                                                                                                                                           -----------------------------------------------------------------------------------------------------------------------------         Monday              Tuesday           Wednesday            Thursday             Friday             Saturday        --------------------+--------------------+--------------------+--------------------+--------------------+--------------------            1                     2                 3                   4                   5                   6                                                                                                                                                                                                                                                                                                                                               +Assemble Tank/,0>                                                              +===============================Excavate/,500.00================================>  +==================Deliver Material/0.00==================+****Independence****+Lay Power Line/,>                      +====================Drill Well/,000.00====================>****Independence****<Drill Well/,000.+                      --------------------+--------------------+--------------------+--------------------+--------------------+--------------------            8                   9                  10                  11                  12                  13                                                                                                                                                                                                                                                               +===========================Build Pump House/,000.00============================+                                          <=============================Assemble Tank/,000.00=============================+                                          <=======Lay Power Line/,000.00========+                                                                                  <Excavate/,500.00>******Vacation******<Excavate/,500.00++=======Pour Foundation/,500.00=======>                      --------------------+--------------------+--------------------+--------------------+--------------------+--------------------           15                  16                  17                  18                  19                  20                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   +=========================================Install Pump/0.00=========================================+                      <=================Pour Foundation/,500.00==================+                    +Install Pipe/,00>                      --------------------+--------------------+--------------------+--------------------+--------------------+--------------------           22                  23                  24                  25                  26                  27                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   +========================================Erect Tower/,500.00=========================================>                      <========Install Pipe/,000.00=========+                                                                                  --------------------+--------------------+--------------------+--------------------+--------------------+--------------------           29                  30                  31                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         <Erect Tower/,500+                                                                                                      ------------------------------------------------------------------------------------------------------------------------------ 
end example
 

Example 5: Schedule Calendar, Blank or with Holidays

Procedure features:

  • PROC CALENDAR statement options:

    • FILL

    • HOLIDATA=

    • INTERVAL=WORKDAY

  • DUR statement

  • HOLIDUR statement

  • HOLISTART statement

  • HOLIVAR statement

This example produces a schedule calendar that displays only holidays. You can use this same code to produce a set of blank calendars by removing the HOLIDATA= option and the HOLISTART, HOLIVAR, and HOLIDUR statements from the PROC CALENDAR step.

Program

Create the activities data set. Specify one activity in the first month and one in the last, each with a duration of 0. PROC CALENDAR does not print activities with zero durations in the output.

 data acts;     input sta : date7. act $ 11-30 dur;     datalines;  01JAN97   Start                 0  31DEC97   Finish                0  ; 

Create the holidays data set.

 data holidays;     input sta : date7. act $ 11-30 dur;     datalines;  01JAN97   New Year's            1  28MAR97   Good Friday           1  30MAY97   Memorial Day          1  04JUL97   Independence Day      1  01SEP97   Labor Day             1  27NOV97   Thanksgiving          2  25DEC97   Christmas Break       5  ; 

Set PAGESIZE= and LINESIZE= appropriately. To create larger boxes for each day in the calendar output, increase the value of PAGESIZE=.

 options nodate pageno=1 linesize=132 pagesize=30; 

Create the calendar. DATA= identifies the activities data set; HOLIDATA= identifies the holidays data set. FILL displays all months, even those with no activities. By default, only months with activities appear in the report. INTERVAL=WORKDAY specifies that activities and holidays are measured in 8-hour days and that PROC CALENDAR schedules activities only Monday through Friday.

 proc calendar data=acts holidata=holidays fill interval=workday; 

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 sta;  dur dur; 

Retrieve holiday information. The HOLISTART, HOLIVAR, and HOLIDUR statements specify the variables in the holidays data set that contain the start date, name, and duration of each holiday, respectively. When you use a holidays data set, HOLISTART is required. Because at least one holiday lasts more than one day, HOLIDUR (or HOLIFIN) is required.

 holistart sta;  holivar act;  holidur dur; 

Specify the title.

 title1 'Calendar of Holidays Only';  run; 

Output

Output 5.9: Schedule Calendars with Holidays Only (Partial Output).
start example

Without INTERVAL=WORKDAY, the 5-day Christmas break would be scheduled through the weekend .

 Calendar of Holidays Only                                                     1 ------------------------------------------------------------------------------------------------------------------------------                                                                                                                                                                                       January  1997                                                                                                                                                                                       -----------------------------------------------------------------------------------------------------------------------------      Sunday           Monday           Tuesday         Wednesday        Thursday          Friday          Saturday      -----------------+-----------------+-----------------+-----------------+-----------------+-----------------+-----------------                                                            1                2                3                4                                                            ***New Years****                                                    -----------------+-----------------+-----------------+-----------------+-----------------+-----------------+-----------------         5                6                7                8                9               10               11                                                                                                                                 -----------------+-----------------+-----------------+-----------------+-----------------+-----------------+-----------------        12               13               14               15               16               17               18                                                                                                                                 -----------------+-----------------+-----------------+-----------------+-----------------+-----------------+-----------------        19               20               21               22               23               24               25                                                                                                                                 -----------------+-----------------+-----------------+-----------------+-----------------+-----------------+-----------------        26               27               28               29               30               31                                                                                                                                                  ------------------------------------------------------------------------------------------------------------------------------ 
 Calendar of Holidays Only                                                    2 ------------------------------------------------------------------------------------------------------------------------------                                                                                                                                                                                      February   1997                                                                                                                                                                                      -----------------------------------------------------------------------------------------------------------------------------      Sunday           Monday           Tuesday         Wednesday        Thursday          Friday          Saturday      -----------------+-----------------+-----------------+-----------------+-----------------+-----------------+-----------------                                                                                                               1                                                                                                                                 -----------------+-----------------+-----------------+-----------------+-----------------+-----------------+-----------------         2                3                4                5                6                7                8                                                                                                                                 -----------------+-----------------+-----------------+-----------------+-----------------+-----------------+-----------------         9               10               11               12               13               14               15                                                                                                                                 -----------------+-----------------+-----------------+-----------------+-----------------+-----------------+-----------------        16               17               18               19               20               21               22                                                                                                                                 -----------------+-----------------+-----------------+-----------------+-----------------+-----------------+-----------------        23               24               25               26               27               28                                                                                                                                                  ------------------------------------------------------------------------------------------------------------------------------ 
 Calendar of Holidays Only                                                    1 ------------------------------------------------------------------------------------------------------------------------------                                                                                                                                                                                      December  1997                                                                                                                                                                                       -----------------------------------------------------------------------------------------------------------------------------      Sunday           Monday           Tuesday         Wednesday        Thursday          Friday          Saturday      -----------------+-----------------+-----------------+-----------------+-----------------+-----------------+-----------------                          1                2                3                4                5                6                                                                                                                                 -----------------+-----------------+-----------------+-----------------+-----------------+-----------------+-----------------         7                8                9               10               11               12               13                                                                                                                                 -----------------+-----------------+-----------------+-----------------+-----------------+-----------------+-----------------        14               15               16               17               18               19               20                                                                                                                                 -----------------+-----------------+-----------------+-----------------+-----------------+-----------------+-----------------        21               22               23               24               25               26               27                                                                             *Christmas Break**Christmas Break*                  -----------------+-----------------+-----------------+-----------------+-----------------+-----------------+-----------------        28               29               30               31                                                                             *Christmas Break**Christmas Break**Christmas Break*                                                    ------------------------------------------------------------------------------------------------------------------------------ 
end example
 

Example 6: Calculating a Schedule Based on Completion of Predecessor Tasks

Procedure features:

  • PROC CALENDAR statement

  • CALID statement

  • FIN statement

  • VAR statement

Other features:

  • PROC CPM step

  • PROC SORT step

Automating Your Scheduling Task with SAS/OR Software

When changes occur to a schedule, you have to adjust the activity starting dates manually if you use PROC CALENDAR to produce a schedule calendar. Alternatively, you can use PROC CPM in SAS/OR software to reschedule work when dates change. Even more important, you can provide only an initial starting date for a project and let PROC CPM calculate starting dates for activities, based on identified successor tasks, that is, tasks that cannot begin until their predecessors end.

In order to use PROC CPM, you must

  1. create an activities data set that contains activities with durations. (You can indicate nonwork days, weekly work schedules, and workshifts with holidays, calendar, and workshift data sets.)

  2. indicate which activities are successors to others (precedence relationships).

  3. define resource limitations if you want them considered in the schedule.

  4. provide an initial starting date.

PROC CPM can process your data to generate a data set that contains the start and end dates for each activity. PROC CPM schedules the activities, based on the duration information, weekly work patterns, workshifts, as well as holidays and nonwork days that interrupt the schedule. You can generate several views of the schedule that is computed by PROC CPM, from a simple listing of start and finish dates to a calendar, a Gantt chart, or a network diagram.

Highlights of This Example

This example

  • calculates a project schedule containing multiple calendars (PROC CPM)

  • produces a listing of the PROC CPM output data set (PROC PRINT)

  • displays the schedule in calendar format (PROC CALENDAR).

This example features PROC CPM s ability to calculate a schedule that

  • is based on an initial starting date

  • applies different non-work periods to different calendars, such as personal vacation days to each employee s schedule

  • includes milestones (activities with a duration of 0).

See Also

This example introduces users of PROC CALENDAR to more advanced SAS scheduling tools. For an introduction to project management tasks and tools and several examples, see Project Management Using the SAS System . For more examples, see SAS/OR Software: Project Management Examples . For complete reference documentation, see SAS/OR User s Guide: Project Management .

Program

Set appropriate options. If the linesize is not long enough to print the variable values, then PROC CALENDAR either truncates the values or produces no calendar output. A longer linesize also makes it easier to view a listing of a PROC CPM output data set.

 options nodate pageno=1 linesize=132 pagesize=60; 

Create the activities data set and identify separate calendars. This data identifies two calendars: the professor s (the value of _CAL_ is Prof. ) and the student s (the value of _CAL_ is Student ). The Succ1 variable identifies which activity cannot begin until the current one ends. For example Analyze Exp 1 cannot begin until Run Exp 1 is completed. The DAYS value of for JOBNUM 3, 6, and 8 indicates that these are milestones.

 data grant;     input jobnum Task $ 4-22 Days Succ1  $ 27-45 aldate : date7. altype $           _cal_ $;     format aldate date7.;     datalines;  1  Run Exp 1          11  Analyze Exp 1        .      .   Student  2  Analyze Exp 1       5  Send Report 1        .      .   Prof.  3  Send Report 1       0  Run Exp 2            .      .   Prof.  4  Run Exp 2          11  Analyze Exp 2        .      .   Student  5  Analyze Exp 2       4  Send Report 2        .      .   Prof.  6  Send Report 2       0  Write Final Report   .      .   Prof.  7  Write Final Report  4  Send Final Report    .      .   Prof.  8  Send Final Report   0                       .      .   Student  9  Site Visit          1                      18jul96 ms  Prof.  ; 

Create the holidays data set and identify which calendar a nonwork day belongs to. The two holidays are listed twice, once for the professor s calendar and once for the student s. Because each person is associated with a separate calendar, PROC CPM can apply the personal vacation days to the appropriate calendars.

 data nowork;     format holista date7. holifin date7.;     input holista : date7. holifin : date7. name $ 17-32 _cal_ $;     datalines;  04jul96 04jul96 Independence Day Prof.  02sep96 02sep96 Labor Day        Prof.  04jul96 04jul96 Independence Day Student  02sep96 02sep96 Labor Day        Student  15jul96 16jul96 PROF Vacation    Prof.  15aug96 16aug96 STUDENT Vacation Student  ; 

Calculate the schedule with PROC CPM. PROC CPM uses information supplied in the activities and holidays data sets to calculate start and finish dates for each activity. The DATE= option supplies the starting date of the project. The CALID statement is not required, even though this example includes two calendars, because the calendar identification variable has the special name _CAL_.

 proc cpm data=grant           date='01jul96'd           interval=weekday           out=gcpm1           holidata=nowork;     activity task;     successor succ1;     duration days;     calid _cal_;     id task;     aligndate aldate;     aligntype altype;     holiday holista / holifin=holifin;  run; 

Print the output data set that was created with PROC CPM. This step is not required. PROC PRINT is a useful way to view the calculations produced by PROC CPM. See Output 5.10.

Output 5.10: The Data Set GCPM1
start example

PROC PRINT displays the observations in GCPM1, showing the scheduling calculations created by PROC CPM.

 Data Set GCPM1, Created with PROC CPM                                                   1 Obs    Task                  Succ1                Days    _cal_    E_START   E_FINISH    L_START    L_FINISH    T_FLOAT    F_FLOAT 1     Run Exp 1             Analyze Exp 1         11    Student   01JUL96   16JUL96     01JUL96    16JUL96        0          0 2     Analyze Exp 1         Send Report 1          5    Prof.     17JUL96   23JUL96     17JUL96    23JUL96        0          0 3     Send Report 1         Run Exp 2              0    Prof.     24JUL96   24JUL96     24JUL96    24JUL96        0          0 4     Run Exp 2             Analyze Exp 2         11    Student   24JUL96   07AUG96     24JUL96    07AUG96        0          0 5     Analyze Exp 2         Send Report 2          4    Prof.     08AUG96   13AUG96     08AUG96    13AUG96        0          0 6     Send Report 2         Write Final Report     0    Prof.     14AUG96   14AUG96     14AUG96    14AUG96        0          0 7     Write Final Report    Send Final Report      4    Prof.     14AUG96   19AUG96     14AUG96    19AUG96        0          0 8     Send Final Report                            0    Student   20AUG96   20AUG96     20AUG96    20AUG96        0          0 9     Site Visit                                   1    Prof.     18JUL96   18JUL96     18JUL96    18JUL96        0          0 
end example
 
 proc print data=gcpm1;     title 'Data Set GCPM1, Created with PROC CPM';  run; 

Sort GCPM1 by the variable that contains the activity start dates before using it with PROC CALENDAR.

 proc sort data=gcpm1;     by e_start;  run; 

Create the schedule calendar. GCPM1 is the activity data set. PROC CALENDAR uses the S_START and S_FINISH dates, calculated by PROC CPM, to print the schedule. The VAR statement selects only the variable TASK to display on the calendar output. See Output 5.11.

Output 5.11: Schedule Calendar Based on Output from PROC CPM
start example

PROC CALENDAR created this schedule calendar by using the S_START and S_FINISH dates that were calculated by PROC CPM. The activities on July 24th and August 14th, because they are milestones, do not delay the start of a successor activity. Note that Site Visit occurs on July 18, the same day that Analyze Exp 1 occurs. To prevent this overallocation of resources, you can use resource constrained scheduling , available in SAS/OR software.

 Schedule for Experiment X-15                                                 2                                                      Professor and Student Schedule            ------------------------------------------------------------------------------------------------------------------------                                                                                                                                                                                                     July  1996                                                                                                                                                                                                  ----------------------------------------------------------------------------------------------------------------------                 Sunday          Monday          Tuesday         Wednesday       Thursday         Friday         Saturday     ----------+----------------+----------------+----------------+----------------+----------------+----------------+----------------                                   1               2                 3               4              5                6       .........................................................................................................................   PROF.                                                                   Independence Day                                  .........................................................................................................................   STUDENT                 +===================Run Exp 1====================>Independence Day<==Run Exp 1==>                                                                                                                                                                                                                                                                        ---------+----------------+----------------+----------------+----------------+----------------+----------------+----------------                   7               8               9                10              11             12               13       .........................................................................................................................   STUDENT                 <====================================Run Exp 1====================================>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              ---------+----------------+----------------+----------------+----------------+----------------+----------------+----------------                  14              15              16                17              18             19               20       .........................................................................................................................   PROF.                   *PROF Vacation***PROF Vacation**                +==Site Visit==+                                                                                           +=================Analyze Exp 1==================>                  .........................................................................................................................   STUDENT                 <===========Run Exp 1===========+                                                                                                                                                                                             ---------+----------------+----------------+----------------+----------------+----------------+----------------+----------------                  21              22              23                24              25             26               27       .........................................................................................................................   PROF.                   <=========Analyze Exp 1=========++Send Report 1=+                                                  .........................................................................................................................   STUDENT                                                 +===================Run Exp 2====================>                                                                                                                                                                                                                                                                        ---------+----------------+----------------+----------------+----------------+----------------+----------------+----------------                  28              29              30                31                                                       .........................................................................................................................   STUDENT                 <===================Run Exp 2====================>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              ----------------------------------------------------------------------------------------------------------------------------------                                                     Schedule for Experiment X-15                                                  3                                                     Professor and Student Schedule            ------------------------------------------------------------------------------------------------------------------------                                                                                                                                                                                                   August  1996                                                                                                                                                                                                  ----------------------------------------------------------------------------------------------------------------------                 Sunday           Monday         Tuesday        Wednesday        Thursday         Friday         Saturday     ----------+----------------+----------------+----------------+----------------+----------------+----------------+----------------                                                                                    1               2               3        .........................................................................................................................   STUDENT                                                                 <===========Run Exp 2===========>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              ---------+----------------+----------------+----------------+----------------+----------------+----------------+----------------                   4                5               6                7              8               9              10        .........................................................................................................................   PROF.                                                                   +=========Analyze Exp 2=========>                  .........................................................................................................................   STUDENT                 <===================Run Exp 2====================+                                                                                                                                                                                                                                                                                                        ---------+----------------+----------------+----------------+----------------+----------------+----------------+----------------                  11               12              13               14             15              16              17        .........................................................................................................................   PROF.                                                   +===============Write Final Report===============>                                           <=========Analyze Exp 2=========++Send Report 2=+                                                  .........................................................................................................................   STUDENT                                                                 STUDENT VacationSTUDENT Vacation                                                                                                                                             ---------+----------------+----------------+----------------+----------------+----------------+----------------+----------------                  18               19              20               21             22              23              24        .........................................................................................................................   PROF.                   <Write Final Re+                                                                                  .........................................................................................................................   STUDENT                                 +Send Final Rep+                                                                                                                                                                                                                                                                                                                        ---------+----------------+----------------+----------------+----------------+----------------+----------------+----------------                  25               26              27               28             29              30              31                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          ---------------------------------------------------------------------------------------------------------------------------------- 
end example
 
 proc calendar data=gcpm1                holidata=nowork                interval=workday;     start e_start;     fin   e_finish;     calid _cal_ / output=combine;     holistart holista;     holifin   holifin;     holivar name;     var task;     title 'Schedule for Experiment X-15';     title2 'Professor and Student Schedule';  run; 

Output

Example 7: Summary Calendar with MEAN Values By Observation

Procedure features:

  • CALID statement:

    • _CAL_ variable

    • OUTPUT=SEPARATE option

  • FORMAT statement

  • LABEL statement

  • MEAN statement

  • SUM statement

Other features:

  • PROC FORMAT:

    • PICTURE statement

  • This example

  • produces a summary calendar

  • displays holidays

  • produces sum and mean values by business day (observation) for three variables

  • prints a legend and uses variable labels

  • uses picture formats to display values.

MEAN Values by Number of Days

To produce MEAN values based on the number of days in the calendar month , use MEANTYPE=NDAYS. By default, MEANTYPE=NOBS, which calculates the MEAN values according to the number of days for which data exists .

Program

Create the activities data set. MEALS records how many meals were served for breakfast , lunch , and dinner on the days that the cafeteria was open for business.

 data meals;     input date : date7. Brkfst Lunch Dinner;     datalines;  02Dec96       123 234 238  03Dec96       188 188 198  04Dec96       123 183 176  05Dec96       200 267 243  06Dec96       176 165 177  09Dec96       178 198 187  10Dec96       165 176 187  11Dec96       187 176 231  12Dec96       176 187 222  13Dec96       187 187 123  16Dec96       176 165 177  17Dec96       156   . 167  18Dec96       198 143 167  19Dec96       178 198 187  20Dec96       165 176 187  23Dec96       187 187 123  ; 

Create the holidays data set.

 data closed;     input date date. holiday $ 11-25;     datalines;  26DEC96   Repairs  27DEC96   Repairs  30DEC96   Repairs  31DEC96   Repairs  24DEC96   Christmas Eve  25DEC96   Christmas  ; 

Sort the activities data set by the activity starting date. You are not required to sort the holidays data set.

 proc sort data=meals;     by date;  run; 

Create picture formats for the variables that indicate how many meals were served.

 proc format;     picture bfmt other = '000 Brkfst';     picture lfmt other = '000 Lunch ';     picture dfmt other = '000 Dinner';  run; 

Set PAGESIZE= and LINESIZE= appropriately. The legend box prints on the next page if PAGESIZE= is not set large enough. LINESIZE= controls the width of the cells in the calendar.

 options nodate pageno=1 linesize=132 pagesize=60; 

Create the summary calendar. DATA= identifies the activities data set; HOLIDATA= identifies the holidays data set. The START statement specifies the variable in the activities data set that contains the activity starting date; START is required.

 proc calendar data=meals holidata=closed;     start date; 

Retrieve holiday information. The HOLISTART and HOLIVAR statements specify the variables in the holidays data set that contain the start date and the name of each holiday, respectively. HOLISTART is required when you use a holidays data set.

 holistart date;  holiname holiday; 

Calculate, label, and format the sum and mean values. The SUM and MEAN statements calculate sum and mean values for three variables and print them with the specified format. The LABEL statement prints a legend and uses labels instead of variable names . The FORMAT statement associates picture formats with three variables.

 sum brkfst lunch dinner / format=4.0;  mean brkfst lunch dinner / format=6.2;  label brkfst = 'Breakfasts Served'        lunch  = '   Lunches Served'        dinner = '   Dinners Served';  format brkfst bfmt.         lunch lfmt.         dinner dfmt.; 

Specify the titles.

 title 'Meals Served in Company Cafeteria';     title2 'Mean Number by Business Day';  run; 

Output

Output 5.12: Summary Calendar with MEAN Values by Observation
start example
 Meals Served in Company Cafeteria                                 1                                  Mean Number by Business Day  -------------------------------------------------------------------------------------------                                                                                                                                   December  1996                                                                                                                                    ------------------------------------------------------------------------------------------     Sunday      Monday     Tuesday    Wednesday    Thursday     Friday     Saturday    ------------+------------+------------+------------+------------+------------+------------        1           2           3           4           5           6           7                                                                                                          123 Brkfst  188 Brkfst  123 Brkfst  200 Brkfst  176 Brkfst                            234 Lunch   188 Lunch   183 Lunch   267 Lunch   165 Lunch                             238 Dinner  198 Dinner  176 Dinner  243 Dinner  177 Dinner               ------------+------------+------------+------------+------------+------------+------------        8           9          10          11          12          13          14                                                                                                          178 Brkfst  165 Brkfst  187 Brkfst  176 Brkfst  187 Brkfst                            198 Lunch   176 Lunch   176 Lunch   187 Lunch   187 Lunch                             187 Dinner  187 Dinner  231 Dinner  222 Dinner  123 Dinner               ------------+------------+------------+------------+------------+------------+------------       15          16          17          18          19          20          21                                                                                                          176 Brkfst  156 Brkfst  198 Brkfst  178 Brkfst  165 Brkfst                            165 Lunch            .  143 Lunch   198 Lunch   176 Lunch                             177 Dinner  167 Dinner  167 Dinner  187 Dinner  187 Dinner               ------------+------------+------------+------------+------------+------------+------------       22          23          24          25          26          27          28                               Christmas Ev*Christmas****Repairs*****Repairs***                           187 Brkfst                                                                            187 Lunch                                                                             123 Dinner                                                               ------------+------------+------------+------------+------------+------------+------------       29          30          31                                                                   **Repairs*****Repairs***                                                                                                                                                                                                                                                                                                                    -------------------------------------------------------------------------------------------                            ------------------------------------                                                Sum    Mean                                                                                              Breakfasts Served  2763  172.69                                  Lunches Served  2830  188.67                                  Dinners Served  2990  186.88                              ------------------------------------ 
end example
 

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

Procedure features:

  • PROC CALENDAR statement options:

    • DATETIME

    • LEGEND

  • CALID statement:

    • _CAL_ variable

    • OUTPUT=SEPARATE option

  • OUTSTART statement

  • OUTFIN statement

  • SUM statement

Data sets:

  • WELL.ACT on page 123 and WELL.HOL on page 123.

This example

  • 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 two things:

  • how the activities data set is sorted

  • how the OUTPUT= option is set.

To print

Sort the activities data set by

And set OUTPUT= to

See Example

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

Specify the SAS data library where the activities data set is stored.

 libname well '  SAS-data-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 PAGESIZE= and LINESIZE= appropriately. The legend box prints on the next page if PAGESIZE= is not set large enough. LINESIZE= controls the width of the boxes.

 options nodate pageno=1 linesize=132 pagesize=60; 

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

Output 5.13: Separated Output for Multiple Summary Calendars
start example
 Well Drilling Cost Summary                                                    1                                                           Separate Calendars  ............................................................ _cal_=CAL1 ............................................................         -------------------------------------------------------------------------------------------------------------------                                                                                                                                                                                      July 1996                                                                                                                                                                                       -----------------------------------------------------------------------------------------------------------------               Monday           Tuesday          Wednesday          Thursday          Friday           Saturday               ------------------+------------------+------------------+------------------+------------------+------------------                  1                 2                 3                 4                5                 6                                                                        ***Independence***                                              Drill Well                                            Lay Power Line    Assemble Tank                                             3.5                                                     3                 4                                    ,000.00                                             ,000.00         ,000.00                            ------------------+------------------+------------------+------------------+------------------+------------------                  8                 9                10                11               12                13                                                                                                                                        Build Pump House                                      Pour Foundation                                                               3                                                     4                                                      ,000.00                                             ,500.00                                              ------------------+------------------+------------------+------------------+------------------+------------------                 15                16                17                18               19                20                                                                                                                                        Install Pump                                                           Install Pipe       Erect Tower                               4                                                                       2                 6                    0.00                                                               ,000.00         ,500.00          ------------------+------------------+------------------+------------------+------------------+------------------                 22                23                24                25               26                27                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      ------------------+------------------+------------------+------------------+------------------+------------------                 29                30                31                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           -------------------------------------------------------------------------------------------------------------------                                                      -------------------------                                                        Legend       Sum                                                                                                                                         task                                                                         dur                                                                          cost      ,500.00                                                        -------------------------                                                      Well Drilling Cost Summary                                                    2                                                           Separate Calendars  ............................................................ _cal_=CAL2 ............................................................           -------------------------------------------------------------------------------------------------------------------                                                                                                                                                                                        July  1996                                                                                                                                                                                            -----------------------------------------------------------------------------------------------------------------                 Monday            Tuesday          Wednesday         Thursday           Friday           Saturday                ------------------+------------------+------------------+------------------+------------------+------------------                    1                  2                  3                4                5                  6                                                                                                                                          Deliver Material                      Excavate                                                                                        2                                4.75                                                                            0.00                           ,500.00                                                                  ------------------+------------------+------------------+------------------+------------------+------------------                     8                 9               10                 11               12                 13                                    *****Vacation*****                                                                                                                                                                                                                                                                                                                                                                                                                                                        ------------------+------------------+------------------+------------------+------------------+------------------                    15                16               17                 18               19                 20                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              ------------------+------------------+------------------+------------------+------------------+------------------                    22                23               24                 25               26                 27                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              ------------------+------------------+------------------+------------------+------------------+------------------                    29                30               31                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     -------------------------------------------------------------------------------------------------------------------                                                       -------------------------                                                         Legend   Sum                                                                                                                                               task                                                                          dur                                                                           cost       ,000.00                                                         ------------------------- 
end example
 



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