The following Stata script produces the subsequent table:
----------------------------------------
| N Mean SD Range
---+------------------------------------
NE | 2096.0 25.6 4.7 (15.4, 57.1)
MW | 2774.0 25.5 4.9 (14.1, 61.1)
S | 2853.0 25.6 5.1 (12.4, 55.4)
W | 2628.0 25.4 4.9 (15.7, 54.1)
----------------------------------------
The rows are categories of the variable region. Is it possible to label that column "Region", as shown below? If so, how?
--------------------------------------------
Region | N Mean SD Range
-------+------------------------------------
NE | 2096.0 25.6 4.7 (15.4, 57.1)
MW | 2774.0 25.5 4.9 (14.1, 61.1)
S | 2853.0 25.6 5.1 (12.4, 55.4)
W | 2628.0 25.4 4.9 (15.7, 54.1)
--------------------------------------------
Kind regards,
Suzanna
After posting I noticed the columns for the tables in this post are not aligned and I can't seem to be able to align them now. Hopefully my question is clear regardless.
Code:
use https://www.stata-press.com/data/r18/nhanes2,clear
collect clear
table (region) (), stat(count bmi) ///
stat(mean bmi) ///
stat(sd bmi) ///
stat(min bmi) ///
stat(max bmi) nototal ///
nformat(%4.0f count mean min max) nformat(%4.1f )
*Creating range, which combines min and max.
collect composite define range = min max, delimiter(", ") trim
collect style cell result[range]#cell_type[item], sformat((%s))
*Labelling the column headers.
collect label levels result count "N", modify
collect label levels result sd "SD", modify
collect label levels result range "Range", modify
*Specifying the layout.
collect layout (region) (result[count mean sd range])
*Hiding the super row for region and horizontally aligning.
collect style header region, title(hide)
collect style cell result, halign(center)
collect preview
| N Mean SD Range
---+------------------------------------
NE | 2096.0 25.6 4.7 (15.4, 57.1)
MW | 2774.0 25.5 4.9 (14.1, 61.1)
S | 2853.0 25.6 5.1 (12.4, 55.4)
W | 2628.0 25.4 4.9 (15.7, 54.1)
----------------------------------------
The rows are categories of the variable region. Is it possible to label that column "Region", as shown below? If so, how?
--------------------------------------------
Region | N Mean SD Range
-------+------------------------------------
NE | 2096.0 25.6 4.7 (15.4, 57.1)
MW | 2774.0 25.5 4.9 (14.1, 61.1)
S | 2853.0 25.6 5.1 (12.4, 55.4)
W | 2628.0 25.4 4.9 (15.7, 54.1)
--------------------------------------------
Kind regards,
Suzanna
After posting I noticed the columns for the tables in this post are not aligned and I can't seem to be able to align them now. Hopefully my question is clear regardless.
Comment