One of my favorite things to do is to write macros to make tables/graphics/reports/etc. Some of my best ones can be found on this site (NEWSURV, MVMODELS, TABLEN, CIRCOS, DATA_SPECS, COMPARE_ALL), and a new one that I have been developing has focused on making a Consort diagram. In the past I've had to use software like Word, Visio, and PowerPoint to make these diagrams as I hadn't found a way to do it programmatically. I've seen cases where an RTF document somehow has numbers filled in to an existing chart, but didn't like that approach.
My macro focuses on using TEXT plots to make the text boxes and then connects them with line statements based on the anchors of the text boxes. Here is an example of one that I made with my current macro:
The macro call that I needed to use to make this was:
%consort(data=for_consort,id=subject,
node=screened randomized treated ntrt4 ntrt8 ntrtv2 surg adj compadj,
split=* arm,
offreason=scrnrsn endatrsn endrsn2)
The options stand for:
DATA: one row per patient data set where the variables to be used in NODE live
ID: patient ID variable used for counts
NODE: list of variables that determine the different nodes (or boxes) in the consort. e.g. randomization, went to surgery, etc. The value of the variable is used as the text in the text box. Should only be one unique value within each branch of the consort. If a patient doesn't exist in the node then the value should be missing for that variable.
SPLIT: Determines when the consort will split. Currently only works with one split, but am working to make it work with more. The node will still be shown (randomization in the above example), and then the split will happen and the counts will be shown for each level of the SPLIT variable. * indicates no split, and the last value of split is carried forward through further nodes if left missing
OFFREASON: When a patient is found in one node but not in the following node, they are counted as going "off treatment" and placed into a box branching from the consort. The reasons listed in the box are pulled from these variables, with the label of the variable being used as the header for the text box. The last variable is carried forward through further nodes if left missing.
The macro calculates the x/y coordinates of the boxes as well as the lines that connect them before drawing. There are also methods within the macro to manually make the dataset for more complicated consorts.
My questions are:
Does the macro call make sense to use?
What are features that you would want in a consort diagram macro?
Has this already been done before? I've seen SAS programs from SAS workers but not using the same methodology or automation
Any feedback or suggestions are appreciated! I've been rather excited by the challenge of making this program.
... View more