I am using dtable to produce a baseline characteristics table for a clinical trial (Stata 19.5). It's such a nice addition to Stata!
The table is a mixture of continuous and categorical variables. For the continuous variables, I would like these presented as median [IQR]. The code I have at the moment is:
Where `ord' is my list of variables. For my continuous variables, this presents them as, for example: 36.0 [30.0 43.0]
I have two questions:
1) For the continuous variables, it would be good to present some variables to 1 dp and some to 0 dp (for example, age might be 24 [22 28], but a lab result might need to be 5.1 [4.8 5.3]). Is it possible to programme this format mix into the code?
2) Can I define the interquartile range format so that there is a dash or comma between the values (eg, 24 [22-28])
Thank you in advance for any help!
The table is a mixture of continuous and categorical variables. For the continuous variables, I would like these presented as median [IQR]. The code I have at the moment is:
Code:
dtable `ord', ///
by(randgroup, nototals) ///
continuous(, statistics(q2 iqi)) ///
factor(, statistics(fvfrequency fvpercent)) ///
nformat(%6.1f q2 q1 q3 fvpercent) ///
nformat(%6.0f fvfrequency) ///
define(iqi = q1 q3) sformat("[%s]" iqi) ///
title("Table 1: Baseline characteristics")
collect export "$results/Table1_BaselineCharacteristics.xlsx", ///
sheet("mITT") modify
I have two questions:
1) For the continuous variables, it would be good to present some variables to 1 dp and some to 0 dp (for example, age might be 24 [22 28], but a lab result might need to be 5.1 [4.8 5.3]). Is it possible to programme this format mix into the code?
2) Can I define the interquartile range format so that there is a dash or comma between the values (eg, 24 [22-28])
Thank you in advance for any help!

Comment