Hello,
I'm using Stata 18 on Windows 10, and trying to make a Table 1 using dtable that will group my results by 2 categorical variables.
Here is a sample of my data:
And here is the code I've used to make a Table 1 with results grouped by visit:
What I'd like to do, if possible, is have the results shown in the table by visit, by baseline_age20.
Thanks in advance.
Meghan
I'm using Stata 18 on Windows 10, and trying to make a Table 1 using dtable that will group my results by 2 categorical variables.
Here is a sample of my data:
Code:
* Example generated by -dataex-. For more info, type help dataex clear input float(pid VISIT age sex_male haz waz bmi bmiz no_scan baseline_age20) 1 1 16.67123 1 -.9703893 -1.0016696 19.330885 -.6707739 0 0 1 2 18.10304 1 -.3789278 -.24052253 21.55985 -.13239644 0 0 1 3 19.247486 1 -.52851653 -.26594642 22.311863 -.10378502 0 0 2 1 14.658868 1 -1.0376383 -1.283121 17.134506 -1.1481297 0 0 2 2 16.230312 1 -.6941634 -.7813833 19.127207 -.6346363 0 0 2 3 17.010616 1 -.7218754 -.743744 19.89619 -.516387 0 0 3 1 17.78282 0 .3419666 1.509787 28.253456 1.4325557 0 0 3 2 19.247486 0 .23503217 1.5211222 29.2352 1.449112 0 0 4 1 17.04621 0 -.7144825 1.4355024 29.809776 1.662931 0 0 4 2 18.472544 0 -.631711 1.3682972 29.66877 1.5481687 0 0 4 3 19.40891 0 -.8471276 1.0972363 28.71389 1.378275 0 0 5 1 12.071432 0 -.5816514 -1.2927265 15.23467 -1.3934557 0 0 5 2 13.604546 0 .23995127 -.29156068 17.553335 -.6020396 0 0 5 3 14.691495 0 .8709965 .2140548 19.101557 -.2229791 0 0 6 1 12.449377 1 -1.6601788 -.8783625 18.626694 .21731845 0 0 7 1 17.37761 1 .7562768 .4490592 21.61769 .0525817 0 0 7 2 19.135233 1 .471106 .22970334 22.222223 -.11331387 0 0 7 3 20.101713 1 .5853121 .4060313 23.015173 .014880114 0 0 8 1 21.123066 1 2.56719 1.0560222 22.301117 -.2259649 1 1 8 2 22.69725 1 2.723965 1.9364756 26.472355 .9306833 1 1 8 3 23.655516 1 2.723965 1.2119988 22.72774 -.07948803 1 1 9 1 16.60552 0 -1.6689416 .0778455 23.97853 .8446057 0 0 9 2 17.563787 0 -1.596563 .11658029 24.35961 .8301668 1 0 9 3 19.11059 0 -1.6119874 .8026524 28.52512 1.3751934 1 0 10 1 14.431622 1 2.3732917 1.0140684 19.12094 -.12046545 0 0 10 2 16.019493 1 2.0195916 1.0367329 20.937077 .13912234 0 0 10 3 16.958595 1 1.991364 1.1388828 22.157425 .3221904 0 0 11 1 16.977762 1 1.0389788 .018491875 19.383274 -.7352784 0 0 11 2 18.565634 1 1.4909267 .11204115 19.903343 -.9232472 0 0 11 3 19.504736 1 1.672129 .05816798 19.84821 -1.1675317 0 0 end label values VISIT VISIT label def VISIT 1 "Visit 1", modify label def VISIT 2 "Visit 2", modify label def VISIT 3 "Visit 3", modify label values sex_male sex label def sex 0 "Female", modify label def sex 1 "Male", modify label values baseline_age20 baseline_age20 label def baseline_age20 0 "20 & under", modify label def baseline_age20 1 "Over 20", modify
Code:
dtable age i.sex_male haz waz bmi bmiz if no_scan == 0, /// by(VISIT, nototals) /// sample(, statistics(freq) place(seplabels)) sformat("(n=%s)" frequency) column(by(hide)) /// define(minmax = min max, delimiter("; ")) /// continuous(age haz waz bmi bmiz, stat(median minmax)) /// nformat(%7.2f median minmax) sformat("(%s)" minmax) /// title(Table 1. Participant Characteristics)
Thanks in advance.
Meghan
Comment