This video demonstrates how to create tables for a regression model using customizable tables in Stata 17. The code below can be used to reproduce the tables shown in this video.
webuse nhanes2l, clear
table, command(regress bpsystol c.age##sex)
table () (result), command(regress bpsystol c.age##sex)
* Selecting estimates
table (colname[c.age 2.sex 2.sex#age _cons]) (result), ///
command(regress bpsystol c.age##sex)
* As above, and selecting results
table (colname[age 2.sex 2.sex#age _cons]) ///
(result[_r_b _r_se _r_z _r_p _r_lb _r_ub]), ///
command(regress bpsystol c.age##sex)
* Modify labels for the specifed results
collect label levels result _r_b "Coef." _r_se "SE" _r_lb ///
"95% lower" _r_ub "95% upper", modify
* Show labels for levels of dimension result
collect style header result, level(label)
collect preview
* Format specified results to three decimal places
collect style cell result[_r_b _r_se _r_lb _r_ub], nformat(%9.3f)
collect preview
* Format p-values to four decimal places
collect style cell result[_r_p], nformat(%5.4f)
collect preview
* Specify the font family
collect style cell, font(arial)
collect preview
* Remove the border on the right side
collect style cell, border(right, pattern(nil))
collect preview
* Set the margins for cells
collect style cell, ///
margin(top, width(5)) margin(right, width(15)) ///
margin(bottom, width(5)) margin(left, width(15))
collect preview
* Export the table to an HTML file
collect export myfile.html
https://www.stata.com