Example 4 — Table of t test results 3
Our table looks much better. Next, we will add labels to the statistics. The statistics are levels of
the new dimensions that we remapped them to. To modify labels for levels of a dimension, we use
collect label levels.
. collect label levels Males N_1 "N" mu_1 "Mean BP"
. collect label levels Females N_2 "N" mu_2 "Mean BP"
. collect label levels Difference p "p-value"
Previously, we saw the column headers Males and Females being repeated. We would like to
display these only once and center them horizontally. We can use collect style column to make
this change. We also set the columns to have the same width. Then, we center-align all the cells
in the table. With collect style cell, we can modify all cells in the table or specific cells. For
example, we wish to format the means and p-values to display two digits to the right of the decimal.
Therefore, we specify the levels of the dimensions we want to apply this format to. Then, we get a
preview of our table.
. collect style column, dups(center) width(equal)
. collect style cell, halign(center)
. collect style cell Males[mu_1] Females[mu_2] Difference[p], nformat(%5.2f)
. collect preview
Males Females Difference
N Mean BP N Mean BP p-value
White 4312 132.85 4753 128.53 0.00
Black 500 133.69 586 133.85 0.92
Other 103 130.67 97 126.72 0.31
Finally, we will modify the borders in the table by using collect style cell. First, we remove
the vertical border. Because we do not want any vertical borders, we do not list any levels of
the dimension border block when we specify the border(right, pattern(nil)) option. Our
next collect style cell command requires a bit more explanation. With it, we add a horizontal
border below Males to indicate that the first N and Mean BP are for males. To target this very
specific border, we specify cell type[column-header]#Males. Here cell type refers to cells
in different parts of the table. We want to make a change only in the column header. We also want
to make this change only for the Males dimension. By specifying the # between the tags, we direct
the change only at the dimension Male within the column headers. We can also target the border
under Females by specifying cell type[column-header]#Females. To this command, we add
the border(bottom, pattern(single)) option to place a single border on the bottom of these
cells.