Chapter Contents |
Previous |
Next |
The GANTT Procedure |
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 = LSTtitle 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
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
Chapter Contents |
Previous |
Next |
Top |
Copyright © 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.