Hello!
Jeff Pitalbo from Stata very kindly helped me with getting row %s using the code below. I need to replicate this for 6 binary outcomes and am getting stuck. I would be grateful for assistance with this. Many thanks!!
Jeff Pitalbo from Stata very kindly helped me with getting row %s using the code below. I need to replicate this for 6 binary outcomes and am getting stuck. I would be grateful for assistance with this. Many thanks!!
HTML Code:
clear all webuse nhanes2l local cvars age weight bpsystol local fvars sex race * compute the summary and continuous variable statistics table () (diabetes), /// statistic(frequency) /// statistic(percent) /// statistic(mean `cvars') /// statistic(sd `cvars') * show "N" for the sample frequency and percents collect recode var _hide = N, fortags(result[frequency percent]) * compute tabulations of each factor variable across levels of diabetes foreach fvar of local fvars { table (`fvar') (diabetes), /// statistic(frequency) /// statistic(percent, across(diabetes)) /// totals(`fvar') /// name(`fvar') } * combine all above collections into a new one called 'all' collect combine all = Table `fvars' * define the composite result similar to that of -dtable- collect composite define /// stats = frequency percent /// mean sd /// , trim collect style autolevels result stats, clear collect style header result[stats], level(hide) * some other -dtable- style choices collect style cell result[percent], sformat("(%s%%)") nformat(%9.1f) collect style cell result[sd], sformat("(%s)") collect style cell result[mean sd], nformat(%9.3f) * arrange the composite results like -dtable- collect layout (var `fvars') (diabetes#result) * publish your table to a supported file format collect export table1b.html, replace
Comment