We are creating a series of process charts (XmR charts) as part of a reporting system for a clinical care pathway for a subset of our patients. Consider the following code:
foreach indicator in unitdelay icutime mobdelay tfeed foleyout downsize decandays decandelay pointake los {
* creates x chart *
twoway (line `indicator' sxdate, sort) (line mean`indicator' sxdate, sort) (line unpl`indicator' sxdate, sort) ///
(line lnpl`indicator' sxdate, sort), ///
xtitle(, size(medsmall)) xlabel(, labsize(vsmall)) ytitle(Days) title(Time till `indicator' (days), ///
size(medium)) legend(off) clegend(position(3)) yscale(range(0 10)) name(`indicator', replace)
graph save "`indicator'", replace
* creates mR chart *
twoway (line mr`indicator' sxdate, sort) (line meanmr`indicator' sxdate, sort) (line url`indicator' sxdate, sort), ///
xtitle(, size(medsmall)) xlabel(, labsize(vsmall)) ytitle(Days) legend(off) yscale(range(0 10)) name(mr`indicator', replace)
graph save "mr`indicator'", replace
* create the XmR chart *
graph combine "`indicator'" "mr`indicator'", cols(1) name(xmr`indicator', replace)
graph save "xmr `indicator'", replace
graph export "xmr `indicator'.tif", replace
}
As a result of the loop, we have a series of 30 graphs in total all saved to disk and also all retained in the graph window. Being able to save all of the graphs collected in the graph window as a single pdf file would make my boss a very happy person. I am aware that we can manually compile these files into a pdf document, but that will be more labour intensive and error prone than we're interested.
There will certainly be some sort of AppleScript that I can run to accomplish this goal. However, the question is whether or not there is some manner to do entirely from within Stata that I can incorporate into my do file.
foreach indicator in unitdelay icutime mobdelay tfeed foleyout downsize decandays decandelay pointake los {
* creates x chart *
twoway (line `indicator' sxdate, sort) (line mean`indicator' sxdate, sort) (line unpl`indicator' sxdate, sort) ///
(line lnpl`indicator' sxdate, sort), ///
xtitle(, size(medsmall)) xlabel(, labsize(vsmall)) ytitle(Days) title(Time till `indicator' (days), ///
size(medium)) legend(off) clegend(position(3)) yscale(range(0 10)) name(`indicator', replace)
graph save "`indicator'", replace
* creates mR chart *
twoway (line mr`indicator' sxdate, sort) (line meanmr`indicator' sxdate, sort) (line url`indicator' sxdate, sort), ///
xtitle(, size(medsmall)) xlabel(, labsize(vsmall)) ytitle(Days) legend(off) yscale(range(0 10)) name(mr`indicator', replace)
graph save "mr`indicator'", replace
* create the XmR chart *
graph combine "`indicator'" "mr`indicator'", cols(1) name(xmr`indicator', replace)
graph save "xmr `indicator'", replace
graph export "xmr `indicator'.tif", replace
}
As a result of the loop, we have a series of 30 graphs in total all saved to disk and also all retained in the graph window. Being able to save all of the graphs collected in the graph window as a single pdf file would make my boss a very happy person. I am aware that we can manually compile these files into a pdf document, but that will be more labour intensive and error prone than we're interested.
There will certainly be some sort of AppleScript that I can run to accomplish this goal. However, the question is whether or not there is some manner to do entirely from within Stata that I can incorporate into my do file.
Comment