The NETDRAW Procedure

Getting Started: NETDRAW Procedure

(View the complete code for this example.)

The first step in defining a project is to make a list of the activities in the project and determine the precedence constraints that need to be satisfied by these activities. It is useful at this stage to view a graphical representation of the project network. In order to draw the network, you specify the nodes of the network and the precedence relationships among them. Consider the software development project that is described in the "Getting Started" section of Chapter 3, The CPM Procedure. The network data are in the SAS data set SOFTWARE, displayed in Figure 1.

Figure 1: Software Project

Software Project
Data Set SOFTWARE

Obsdescrptdurationactivitysuccesr1succesr2
1Initial Testing20TESTINGRECODE 
2Prel. Documentation15PRELDOCDOCEDREVQATEST
3Meet Marketing1MEETMKTRECODE 
4Recoding5RECODEDOCEDREVQATEST
5QA Test Approve10QATESTPROD 
6Doc. Edit and Revise10DOCEDREVPROD 
7Production1PROD  


The following code produces the network diagram shown in Figure 2:

pattern1 v=e c=green;
pattern2 v=e c=red;

title h=3 'Software Project';
proc netdraw graphics data=software;
   actnet / act=activity htext=2
            succ=(succesr1 succesr2)
            pcompress separatearcs;
   run;

Figure 2: Software Project

Software Project


The procedure determines the placement of the nodes and the routing of the arcs on the basis of the topological ordering of the nodes and attempts to produce a compact diagram. You can control the placement of the nodes by specifying explicitly the node positions. The data set SOFTNET, shown in Figure 3, includes the variables _X_ and _Y_, which specify the desired node coordinates. Note that the precedence information is conveyed using a single SUCCESSOR variable unlike the data set SOFTWARE, which contains two SUCCESSOR variables.

Figure 3: Software Project: Specify Node Positions

Software Project
Data Set SOFTNET

Obsdescrptdurationactivitysuccesor_x__y_
1Initial Testing20TESTINGRECODE11
2Meet Marketing1MEETMKTRECODE12
3Prel. Documentation15PRELDOCDOCEDREV13
4Prel. Documentation15PRELDOCQATEST13
5Recoding5RECODEDOCEDREV22
6Recoding5RECODEQATEST22
7QA Test Approve10QATESTPROD33
8Doc. Edit and Revise10DOCEDREVPROD31
9Production1PROD 42


The following code produces a network diagram (shown in Figure 4) with the new node placement:

title h=3 'Software Project';
title2 h=2 'Controlled Layout';
proc netdraw graphics data=softnet;
   actnet / act=activity htext=1.25
            succ=(succesor)
            pcompress;
   run;

Figure 4: Software Project: Controlled Layout

Software Project: Controlled Layout


Figure 5: Software Project Schedule

Software Project
Project Schedule

descrptactivitysuccesr1succesr2durationE_STARTE_FINISHL_STARTL_FINISHT_FLOATF_FLOAT
Initial TestingTESTINGRECODE 2001MAR0420MAR0401MAR0420MAR0400
Prel. DocumentationPRELDOCDOCEDREVQATEST1501MAR0415MAR0411MAR0425MAR041010
Meet MarketingMEETMKTRECODE 101MAR0401MAR0420MAR0420MAR041919
RecodingRECODEDOCEDREVQATEST521MAR0425MAR0421MAR0425MAR0400
QA Test ApproveQATESTPROD 1026MAR0404APR0426MAR0404APR0400
Doc. Edit and ReviseDOCEDREVPROD 1026MAR0404APR0426MAR0404APR0400
ProductionPROD  105APR0405APR0405APR0405APR0400


While the project is in progress, you may want to use the network diagram to show the current status of each activity as well as any other relevant information about each activity. PROC NETDRAW can also be used to produce a time-scaled network diagram using the schedule produced by PROC CPM. The schedule data for the software project described earlier are saved in a data set, INTRO1, which is shown in Figure 5.

To produce a time-scaled network diagram, use the TIMESCALE option in the ACTNET statement, as shown in the following program. The MININTERVAL= and the LINEAR options are used to control the time axis on the diagram. The ID=, NOLABEL, and NODEFID options control the amount of information displayed within each node. The resulting diagram is shown in Figure 6.

title h=3 'Software Project';
title2 h=2 'Time-Scaled Diagram';
proc netdraw graphics data=intro1;
   actnet / act=activity succ=(succ:)
            separatearcs pcompress htext=2
            timescale linear frame mininterval=week
            id=(activity duration) nolabel nodefid;
   run;

Figure 6: Software Project: Time-Scaled Network Diagram

Software Project: Time-Scaled Network Diagram


Several other options are available to control the layout of the nodes, the appearance of the network, and the format of the time axis. For projects that have natural divisions, you can use the ZONE= option to divide the network into horizontal zones or bands. For networks that have an embedded tree structure, you can use the TREE option to draw the network like a tree laid out from left to right, with the root at the left edge of the diagram; in graphics mode, you can obtain a top-down tree with the root at the top of the diagram. For cyclic networks you can use the BREAKCYCLE option to enable the procedure to break cycles. All of these options are discussed in detail in the following sections.

Last updated: November 10, 2025