Sankey Diagrams have found increasing favor for visualization of data. This visualization tool has been around for a long time, traditionally used to visualize the flow of energy, or materials. .
Now to be sure, GTL does have a statement design for a Sankey Diagram which was implemented only in Flex for use in interactive visualization cases. The GTL Sankey Diagram statement was not implemented for use in MVA visualization cases due to lack of demand.
However, recently a SAS user asked about creating such graphs using SAS MVA graphics tools. With SAS 9.4 there are sufficient tools in place to create such a diagram using custom coding without use of annotation. In SAS 9.4M3, more tools are available that makes this task easier. I have outlined the process below.
The diagram created using the SAS 9.4 SGPLOT procedure is shown on the right. Click on the diagram to see bigger view. Since no SANKEY statement is available in SGPLOT, such a diagram requires custom coding. However, no annotation is required. The program uses the following statements:
- Series with SmoothConnect for the curves.
- Highlow plots nodes and link values.
- Scatter plot with MarkerChar for node labels.
- Series plot to draw the brackets.
- Scatter plot with MarkerChar for labels 1,2,3.
A custom data set has to be created to draw the different parts of the diagram as shown in the attached program link at the bottom.
The diagram shown on the right uses the new SPLINE statement to be released soon with SAS 9.4M3. This makes the process a little easier, as the spline is a smooth curve that does not need to pass through each of the vertex points. The SAS 9.4M3 SGPLOT also supports varying line thickness for series and spline statements.
Clearly the data is hand-built for this particular diagram. I believe this process can be converted to a macro to create a Sankey Diagram from a node-link data set with the appropriate information. Things will get more interesting as the diagram includes links splits or merges at various nodes.
SAS 9.4 SGPLOT Code: Sankey_940