Resources

Segmented Gantt Charts (gantt24)

/****************************************************************/
/*          S A S   S A M P L E   L I B R A R Y                 */
/*                                                              */
/*    NAME: GANTT24                                             */
/*   TITLE: Segmented Gantt Charts (gantt24)                    */
/* PRODUCT: OR                                                  */
/*  SYSTEM: ALL                                                 */
/*    KEYS: GANTT                                               */
/*   PROCS: CPM, SORT, GANTT                                    */
/*    DATA:                                                     */
/*                                                              */
/* SUPPORT:                             UPDATE:                 */
/*     REF: Example 24 in the GANTT Chapter (PM User's Guide)   */
/*    MISC: Using the SEGMT_NO variable to produce segmented    */
/*             Gantt charts                                     */
/*                                                              */
/****************************************************************/

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


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

/* 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;
   output;
   run;


proc print data=newsched;
   title2 'Data NEWSCHED';
   run;

data labels;
   _y=-1;
   _lvar="city";
   _xvar="from";
   _flabel="";
   _hlabel=0.75;
   _yoffset = -.2;
   run;


* set up required pattern statements;
pattern1 v=s r=25;

* set graphics options;
goptions htext=1.1;

title1 h=2 'Gantt Example 24';
title2 h=1.5 'Schedule of Cities Visited by Salesperson';
proc gantt graphics data=newsched labdata=labels;
id person;
chart / ss=from sf=to compress labsplit='.' scale=2
        nolegend nojobnum skip=3
        ref='01may04'd to '30jun04'd by week;
run;