filmov
tv
Customizable tables in Stata 17: Two-way tables of summary statistics
Показать описание
This video demonstrates how to create two-way tables of summary statistics using customizable tables in Stata 17. The code below can be used to reproduce the tables shown in this video.
webuse nhanes2l, clear
* Table of frequencies
table (sex race)
* Suppress the totals
table (sex race), nototals
* Add percentages
table (sex race), nototals statistic(freq) statistic(percent)
* Add the mean and standard deviation of age
table (sex race), nototals statistic(freq) statistic(percent) ///
statistic(mean age) statistic(sd age)
* Format the percentages
table (sex race), nototals statistic(freq) statistic(percent) ///
statistic(mean age) statistic(sd age) nformat(%9.1f percent) ///
sformat(%s%% percent)
* Format the means and standard deviations as well
table (sex race), nototals statistic(freq) statistic(percent) ///
statistic(mean age) statistic(sd age) nformat(%9.1f percent mean sd) ///
sformat(%s%% percent)
* Modify the label for the standard deviations
collect label levels result sd "SD", modify
* Remove the border on the right side and change the font
collect style cell, border(right, pattern(nil)) font(arial)
* Export the table to a .docx file
webuse nhanes2l, clear
* Table of frequencies
table (sex race)
* Suppress the totals
table (sex race), nototals
* Add percentages
table (sex race), nototals statistic(freq) statistic(percent)
* Add the mean and standard deviation of age
table (sex race), nototals statistic(freq) statistic(percent) ///
statistic(mean age) statistic(sd age)
* Format the percentages
table (sex race), nototals statistic(freq) statistic(percent) ///
statistic(mean age) statistic(sd age) nformat(%9.1f percent) ///
sformat(%s%% percent)
* Format the means and standard deviations as well
table (sex race), nototals statistic(freq) statistic(percent) ///
statistic(mean age) statistic(sd age) nformat(%9.1f percent mean sd) ///
sformat(%s%% percent)
* Modify the label for the standard deviations
collect label levels result sd "SD", modify
* Remove the border on the right side and change the font
collect style cell, border(right, pattern(nil)) font(arial)
* Export the table to a .docx file
Комментарии