Chapter Contents
Chapter Contents
The GANTT Procedure

Example 4.24: Multi-Segment Gantt Charts

The following is a simple example that illustrates the generation of multisegmented Gantt charts. The SCHED data set identifies the city, the arrival time, and the departure time for each of four traveling salespeople. In addition, a _PATTERN variable is used to identify the pattern to be used for drawing the bar. The objective is to display the complete schedule for each sales person on a single row. This would require displaying several bars on a single row, each bar corresponding to the time spent in a city. In order to do this, you need first to sort the SCHED data set by Salesperson and Arrival Time and then to add a SEGMT_NO variable that identifies the number of the segment that, in this case, is the order in which the salesperson visits the city. The resulting data set, NEWSCHED, is shown in Output 4.24.1. You next create the LABELS data set in order to identify the names of the Cities above the bars; the resulting Gantt chart is shown in Output 4.24.2.

Notice that each bar is drawn using the pattern identified by the _PATTERN variable in the SCHED data set. In the absence of the _PATTERN variable, the pattern associated with the resource-constrained schedule would have been used for all the bars. This is the same mechanism that produced the split segments in Example 4.13 although the SEGMT_NO variable in this case was automatically created by the CPM procedure.

title1 'Gantt Example 24';
title2 f=swiss 'Schedule of Cities Visited by Salesperson';

data sched;
input person : $ city $9-20 from :  date7. to : date7. _pattern;
format from to date7.;
Clark   New York    01May95 03May95 10
Clark   Boston      06May95 09May95 11
Clark   Wisconsin   12May95 15May95 12
Clark   Chicago     18May95 24May95 13
Clark   New York    28May95 02Jun95 10
Stevens Charlotte   02May95 04May95 14
Stevens Atlanta     08May95 10May95 15
Stevens Dallas      12May95 15May95 16
Stevens Denver      17May95 20May95 17
Stevens Nashville   27May95 02Jun95 18
Stevens Charlotte   04Jun95 06Jun95 14
Jackson Los Angeles 01May95 08May95 19
Jackson Las Vegas   11May95 18May95 20
Jackson Portland    21May95 23May95 21
Jackson Seattle     25May95 29May95 22
Rogers  Miami       02May95 07May95 23
Rogers  Tampa       11May95 15May95 24
Rogers  New Orleans 18May95 24May95 25
Rogers  Houston     28May95 01Jun95 26

/* Sort data by person, from */
proc sort data=sched;
by person from;

/* Add Segmt_no variable */
data newsched;
set sched;
retain segmt_no;
if person ne lag(person) then segmt_no=1;
else segmt_no = segmt_no + 1;

proc print data=sched;

data labels;
_yoffset = -.2;

pattern1 v=s r=25;

proc gantt data=newsched labdata=labels;
id person;
chart / ss=from sf=to compress labsplit='.' scale=2
        nolegend nojobnum skip=3 font=swiss
        ref='01may95'd to '30jun95'd by week

Output 4.24.1: NEWSCHED Data Set

The SAS System

Obs person city from to _pattern segmt_no
1 Clark New York 01MAY95 03MAY95 10 1
2 Clark Boston 06MAY95 09MAY95 11 2
3 Clark Wisconsin 12MAY95 15MAY95 12 3
4 Clark Chicago 18MAY95 24MAY95 13 4
5 Clark New York 28MAY95 02JUN95 10 5
6 Jackson Los Angeles 01MAY95 08MAY95 19 1
7 Jackson Las Vegas 11MAY95 18MAY95 20 2
8 Jackson Portland 21MAY95 23MAY95 21 3
9 Jackson Seattle 25MAY95 29MAY95 22 4
10 Rogers Miami 02MAY95 07MAY95 23 1
11 Rogers Tampa 11MAY95 15MAY95 24 2
12 Rogers New Orleans 18MAY95 24MAY95 25 3
13 Rogers Houston 28MAY95 01JUN95 26 4
14 Stevens Charlotte 02MAY95 04MAY95 14 1
15 Stevens Atlanta 08MAY95 10MAY95 15 2
16 Stevens Dallas 12MAY95 15MAY95 16 3
17 Stevens Denver 17MAY95 20MAY95 17 4
18 Stevens Nashville 27MAY95 02JUN95 18 5
19 Stevens Charlotte 04JUN95 06JUN95 14 6

Output 4.24.2: Multi-Segment Gantt Chart
ga24.gif (7235 bytes)

Chapter Contents
Chapter Contents

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