Over the past few weeks I have heard about the "Consort Diagram". This was mentioned in a Communities article, and also by a couple of users separately.
This topic was also covered by Anusha Mallavarapu and Dean Shults from Cytel in a poster at PhUSE 2016 as shown on the right. The authors discuss an automated way to create the diagram using RTF template.
Speaking with the author, it appears that the diagram structure is relatively fixed for a set number of arms of the study. The authors showed a sample diagram for a 4 arm study shown on the right.
I thought it would be an interesting exercise to see if I could create this diagram fully in SAS, thereby reducing the complexity of using multiple tools. The diagram I created is meant to essentially mimic the diagram presented by the authors above. I have not filled in every box, but did one of each to see how we can create such a graph using the SGPLOT procedure. Other diagram structures could be defined in a similar way.
- A Series plot to draw the links.
- A Polygon plot to draw the empty boxes.
- A Polygon plot to draw the filled boxes.
- A Text plot to draw the center aligned horizontal text.
- A Text plot to draw the left aligned horizontal text.
- A Text plot to draw the rotated text in the filled boxes.
The full program is linked below. The diagram is created in a 0-200 vertical and 0-100 horizontal space. Vertices for the links are defined as nodes data set with Node Id and their (x, y) coordinates based on the shape of the diagram. A Hash Object is created to hold the node ids and their x and y coordinates.
Links are defined as multi segment lines with the Node Ids as vertices. Up to 4 nodes can be used to allow for the angled links. Then, the Node Hash Object is used to get the coordinates of the vertices for the links, and written out as a series plot with multiple legs. Separate data sets are defined for the empty rectangles, and for the filled rectangles so two Polygon statements can be used to draw these, one for empty and one for filled.
While I defined the polygon vertices directly for ease of use, this could also be based on the Node Ids from the Hash Object.
Similarly, text is defined in three data sets, one for the rotated text, one for the center aligned text and one for the left aligned text. These are used with the three Text statements to draw the information. a FitPolicy=SplitAlways is used with a SplitChar="." to arrange the text. Finally, all the data sets are merged into one data set for use with the procedure.
I defined the text location directly for ease of use, but that could also be associated to the Node Ids and extracted from the Hash Object.
My goal is to show how the data should be arranged and which statements to use to draw the graph. The authors indicated that often the Consort Diagram structure and textual information (except the numbers) is static, with changing numbers. In that case, the diagram can be defined once and reused. The "N" values can likely be held in macro variables and inserted into the right places.
SAS 9.40M3 is necessary as I have used the TEXT plot statement to draw the text in the nodes. It may be possible to do this using Annotate with earlier versions, likely a bit harder. I would be interested to hear if this helps in the task, and what other details may need to be addressed. So, please feel free to chime in.
SAS 9.4 SGPLOT Code: consort_diagram