Stata: CONSORT Flowchart

Standard

The CONSORT flowchart for randomised controlled trials has become a standard requirement when publishing medical and social science research (see http://www.consort-statement.org/).

For me it is a regular powerpointpain (e.g. here: http://onlinelibrary.wiley.com/enhanced/doi/10.1111/jsr.12135/). I always thought it would be nice to be able to populate the flow diagram automatically.

I recently figured out how to get Stata to draw stuff. Thus here the flow chart draw by Stata (12.0).

flowchart

CONSORT Flowchart in Stata

CONSORT flowchart in Stata (pdf, high resolution)

And here the do-file, which produced the flowchart, nothing fancy, but maybe helpful:

*Definition of boxes and line styles.
local osmall = 	", box margin(small) size(vsmall)"
local omain =	", box margin(small)"
local bc = ", lwidth(medthick) lcolor(black)" 
local bca = ", lwidth(medthick) lcolor(black) mlcolor(black) mlwidth(medthick) msize(medlarge)"

*Drawing the graph
twoway  /// 1) PCI to draw a box 2) PIC horizontal lines 3) pcarrowi: connecting arrows.
   pci 5.2 0 5.2 6 `bc' || pci 5.2 6 0 6 `bc' || pci 0 6 0 0 `bc' || pci 0 0 5.2 0 `bc' ///
|| pci 3 1.5 3 4.5 `bc' || pci 1.9 1.5 1.9 4.5 `bc' || pci 0.9 1.5 0.9 4.5 `bc' ///
|| pcarrowi 5 3 3.5 3 `bca' ///
|| pcarrowi 4.35 3 4.35 3.35 `bca'  ///
|| pcarrowi 3.5 3 3.2 3 `bca'  ///
|| pcarrowi 3 3 2.1 3 `bca'  ///
|| pcarrowi 1.9 3 1.1 3 `bca'  ///
, /// Text placed using "added text" [ACHTUNG sizes change with content]
text(5 3 "Assessed for eligibility (n= )" `omain') ///
text(4.35 4.5 "Excluded ""(n= )" ///
		"Not meeting inclusion criteria " ///
		"(n= )" ///
		"Declined to participate " ///
		"(n= )" ///
		"Other reasons""(n= )" `osmall') ///
text(3.5 3 "Randomized (n= )" `omain') ///
text(3.1 3 "Allocation"  ) ///
text(2.5 1.5 "ACTIVE" ///
		"Allocated to intervention""(n=)" ///
		"Received allocated intervention ""(n=XXX)" ///
		"Did not receive allocated intervention " ///
		"(give reasons)" ///
		"(n= )" `osmall') ///
text(2.5 4.5 "CONTROL" ///
		 "Allocated to intervention" ///
		 "(n= )""Received allocated intervention " ///
		 "(n= )" /// 
		 "Did not receive allocated intervention " ///
		 "(give reasons)" ///
		 "(n= )" `osmall') ///
text(2 3 "Follow-Up" ) ///
text(1.5 1.5 "Lost to follow-up" ///
	"(give reasons)" ///
	"(n= )" ///
	"Discontinued intervention " ///
	"(give reasons)" ///
	"(n= )" `osmall') ///
text(1.5 4.5 "Lost to follow-up" ///
	"(give reasons)" ///
	"(n= )" ///
	"Discontinued intervention " ///
	"(give reasons)" ///
	" (n= )" `osmall') ///
text(1 3 "Analysis" ) ///
text(0.5 1.5 "Analysed" ///
	"(n= )" ///
	"Excluded from analysis" ///
	"(give reasons)" ///
	"(n= )" `osmall') ///
text(0.5 4.5 "Analysed" ///
	"(n= )" ///
	"Excluded from analysis " ///
	"(give reasons)" ///
	"(n= )" `osmall') /// 
legend(off) ///
xlabel("") ylabel("") xtitle("") ytitle("") ///
plotregion(lcolor(black)) ///
graphregion(lcolor(black)) xscale(range(0 6)) ///
xsize(2) ysize(3) /// A4 aspect ratio
title("Consort Flowchart") ///
note("{bf: Adapted from:} www.consort-statement.org/consort-statement/flow-diagram" ///
, size(tiny))

Anyone who fancies can just put a local to automatically fill the flowchart.

 sum participants if(group == "control")
local allocated control = r(N)