Chapter Contents
Chapter Contents
Previous
Previous
Next
Next
The GANTT Procedure

Example 4.21: Using the SAS/GRAPH ANNOTATE= Option

This example illustrates the use of the ANNOTATE= option to add graphics and text to the body of the Gantt chart. The intent of the first invocation of PROC GANTT is to display the resource requirements of each activity on the Gantt chart, while that of the second invocation is to plot the resource usage bar chart for the replenishable resource engineers and the resource availability curve for the consumable resource cost.

The data for this example come from Example 2.15, in which the widget manufacturing project is scheduled using PROC CPM subject to resource constraints. The project network is defined in the WIDGRES data set via AOA format. The number of engineers needed per day per activity is a replenishable resource and is identified by the ENGINEER variable in the WIDGRES data set. The cost incurred per day per activity is a consumable resource and is identified by the ENGCOST variable in the WIDGRES data set. The WIDGRIN data set specifies the resource availabilities for the project. The schedule produced by PROC CPM using the default choice of LST as a heuristic is shown in Output 4.21.1. The following programs assume that the schedule is stored in the WIDGSCH2 data set and that the resource usage is stored in the WIDGROU2 data set.

The Annotate macros are used in this example to simplify the process of creating Annotate observations. The ANNOMAC macro is first used to compile the Annotate macros and make them available for use. The Annotate data set ANNO1 is then created using the Annotate macros. The DCLANNO macro declares all Annotate variables except the TEXT variable, and the SYSTEM macro defines the Annotate reference system. The coordinate system defined here uses date for the horizontal scale and job number for the vertical scale. The text to be displayed contains the number of engineers required per day and the total cost over the duration of the activity. The LABEL macro is used to annotate the necessary text on the Gantt chart using the BRUSH font.

The GANTT procedure is invoked with the ANNOTATE=ANNO1 specification in the PROC GANTT statement. The resulting Gantt chart is shown in Output 4.21.2. It is important to note that the job number will be used for the vertical scale even if NOJOBNUM is specified in the CHART statement.

Output 4.21.1: Resource Constrained Schedule: Rule = LST

Gantt Example 21
Resource Constrained Schedule: Rule = LST

Obs tail head days task engineer engcost S_START S_FINISH E_START E_FINISH L_START L_FINISH R_DELAY DELAY_R SUPPL_R
1 1 2 5 Approve Plan 2 400 02DEC91 06DEC91 02DEC91 06DEC91 02DEC91 06DEC91 0    
2 2 3 10 Drawings 1 200 09DEC91 20DEC91 09DEC91 20DEC91 09DEC91 20DEC91 0    
3 2 4 5 Anal. Market 1 200 16DEC91 20DEC91 09DEC91 13DEC91 22JAN92 28JAN92 5 engineer  
4 2 3 5 Write Specs 2 400 09DEC91 13DEC91 09DEC91 13DEC91 16DEC91 20DEC91 0    
5 3 5 15 Prototype 4 800 27DEC91 17JAN92 23DEC91 14JAN92 23DEC91 14JAN92 3 engineer  
6 4 6 10 Mkt. Strat. . . 23DEC91 07JAN92 16DEC91 30DEC91 29JAN92 11FEB92 0    
7 5 7 10 Materials . . 20JAN92 31JAN92 15JAN92 28JAN92 15JAN92 28JAN92 0    
8 5 7 10 Facility 2 400 20JAN92 31JAN92 15JAN92 28JAN92 15JAN92 28JAN92 0    
9 7 8 10 Init. Prod. 4 800 03FEB92 14FEB92 29JAN92 11FEB92 29JAN92 11FEB92 0    
10 8 9 10 Evaluate 1 200 17FEB92 28FEB92 12FEB92 25FEB92 19FEB92 03MAR92 0    
11 6 9 15 Test Market . . 17FEB92 06MAR92 12FEB92 03MAR92 12FEB92 03MAR92 0    
12 9 10 5 Changes 2 400 09MAR92 13MAR92 04MAR92 10MAR92 04MAR92 10MAR92 0    
13 10 11 0 Production 4 800 16MAR92 16MAR92 11MAR92 11MAR92 11MAR92 11MAR92 0    
14 6 12 0 Marketing . . 17FEB92 17FEB92 12FEB92 12FEB92 11MAR92 11MAR92 0    
15 8 6 0 Dummy . . 17FEB92 17FEB92 12FEB92 12FEB92 12FEB92 12FEB92 0    


   title c=black f=swiss 'Gantt Example 21';
   title2 c=black f=swiss
          'Displaying Resource Requirements';


   * set background to white and text to black;

   goptions ctext=black cback=white ftext=swiss border;


   * set vpos to 50 and hpos to 100;

   goptions vpos=50 hpos=100;


   * set up required pattern statements;

   pattern1 c=green v=s;  /* duration of a noncrit. activity  */
   pattern2 c=green v=e;  /* slack time for a noncrit. act.   */
   pattern3 c=red   v=s;  /* duration of a critical activity  */
   pattern4 c=red   v=e;  /* slack time for a supercrit. act. */
   pattern5 c=red   v=r2; /* duration of a supercrit. act.    */
   pattern6 c=cyan  v=s;  /* actual duration of an activity   */
   pattern7 c=black v=x1; /* break due to a holiday           */
   pattern8 c=blue  v=s;  /* res. constrained dur of an act.  */


   * begin annotate process;

   * compile annotate macros;

   %annomac;


   * create Annotate data set for first chart;

   data anno1;
      %dclanno;      /* set length and type for annotate vars */
      %system(2,2,4); /* define annotate reference system     */
      set widgsch2;
      length lab $20;
      length text $ 37;
      Y1 = _n_;
      lab='    ';

      if _n_=1 then do;
         %label('02dec91'd,13,
                'Format: Engineers per day, Total cost',
                *,0,0,1.2,brush,6);
         end;

      if engineer ^= . then do;
         /* create a text label */
         lab = put(engineer, 1.) || " Engineer";
         if engineer > 1 then lab = trim(lab) || "s";
         if days > 0 then lab = trim(lab) || ", " ||
                                put(engcost*days, dollar7.);

         /* position the text label */
         if y1 < 10 then do;
            x1 = max(l_finish, s_finish) + 2;
            %label(x1,y1,lab,black,0,0,1.0,brush, 6);
            end;
         else do;
            x1 = e_start - 2;
            %label(x1,y1,lab,black,0,0,1.0,brush, 4);
            end;
         end;
   run;



   * annotate the Gantt chart;

   proc gantt data=widgsch2 holidata=holdata
              annotate=anno1;
      chart / holiday=(hol) interval=weekday increment=7
              ref='1dec91'd to '22mar92'd by week
              cref=blue lref=2
              dur=days cmile=cyan caxis=black
              compress ;
      id task;
   run;

Output 4.21.2: Using the ANNOTATE= Option
ga21p1.gif (8865 bytes)

The next illustration of the ANNOTATE= option is to plot the resource usage bar chart for the replenishable resource engineers and the resource availability curve for the consumable resource cost. A DATA step determines the largest value of the cost availability throughout the life of the project in order to scale the costs accordingly. The CSCALE macro variable is required to represent cost availabilities on the Gantt chart. Since there are no further cash inflows after December 2, 1991, and there are 15 jobs represented on the chart, the value of the macro variable CSCALE is (15-1)/40000.

An Annotate data set, ANNO2, is created in much the same fashion as ANNO1; but it employs some additional macros. The BAR macro is used to draw the resource usage bar chart, and the DRAW and MOVE macros are used to draw the resource availability curve. The PUSH and POP macros are used as necessary to store and retrieve the last used coordinates from the stack, respectively.

   title2 c=black f=swiss
          'Plotting Resource Usage and Resource Availability';


   * calculate scaling factor for cost curve;

   data _null_;
      set widgrou2 end=final;
      retain maxcost;
      if aengcost > maxcost then maxcost=aengcost;
   if final then call symput('cscale', 14/maxcost);
   run;


   * create Annotate data set for second chart;

   data anno2;
      %dclanno;      /* set length and type for annotate vars */
      %system(2,2,4); /* define annotate reference system     */
      set widgrou2;
      length lab $16;
      length text $27;
      x1=_time_;
      y1=15-aengcost*symget('cscale');
      y2=15-rengieer;
      lab='    ';

      if _n_=1 then do;
         /* print labels */
         do i = 1 to 14 by 1;
            lab=put( (15-i) / symget('cscale'), dollar7.);
            %label('22mar92'd,i,lab,black,0,0,1.0,swiss,4);
            end;
         do i = 0 to 4 by 1;
            lab=put(i,1. );
            %label('01dec91'd,15-i,lab,black,0,0,1.0,swiss,6);
            end;
         %label('01dec91'd,10,'Resource Usage: Engineers',
                *,0,0,1.2,swiss,6);
         %label('03jan92'd,4,'Resource Availability: Cost',
                *,0,0,1.2,swiss,6);
         %move(x1,y1);
         %push;
         end;
      else do;
         /* draw cost availability curve */
         %pop;
         when='a';
         %draw(x1,y1,black,1,2);
         %push;
         /* draw engineer usage barchart */
         when='b';
         if y2 <= 14 then do;
            %bar(x1,15,x1+1,y2,blue,0,l1);
            end;
         end;
   run;



    * annotate the Gantt chart;

   proc gantt data=widgsch2 holidata=holdata
              annotate=anno2;
      chart / holiday=(hol) interval=weekday increment=7
              mindate='1dec91'd maxdate='22mar92'd
              ref='1dec91'd to '22mar92'd by week
              cref=blue lref=2
              dur=days cmile=cyan caxis=black
              compress;
      id task;
   run;

Output 4.21.3: Using the ANNOTATE= Option
ga21p2.gif (11245 bytes)

Chapter Contents
Chapter Contents
Previous
Previous
Next
Next
Top
Top

Copyright © 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.