Customizable tables in Stata 17: One-way tables of summary statistics
Ғылым және технология
This video demonstrates how to create one-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)
* Suppress the marginal totals
table () (sex), nototals
* Add percentages, means, and standard deviations
table () (sex), statistic(frequency) statistic(percent) ///
statistic(mean age height weight) statistic(sd age height weight)
* Format the percentages to one decimal place and display them with a %
table () (sex), statistic(frequency) statistic(percent) ///
statistic(mean age height weight) statistic(sd age height weight) ///
nformat(%9.1f percent) sformat("%s%%" percent)
* Format the means and standard deviations to one decimal place
table () (sex), statistic(frequency) statistic(percent) ///
statistic(mean age height weight) statistic(sd age height weight) ///
nformat(%9.1f percent) sformat("%s%%" percent) ///
nformat(%9.1f mean) nformat(%9.1f sd)
/* Group the results by variable name by placing the variables
from the statistic() options on the rows */
table (var) (sex), statistic(frequency) statistic(percent) ///
statistic(mean age height weight) statistic(sd age height weight) ///
nformat(%9.1f percent) sformat("%s%%" percent) ///
nformat(%9.1f mean) nformat(%9.1f sd)
* Remove the right border
collect style cell, border(right, pattern(nil))
* Change the font to arial
collect style cell, font(arial)
* Preview the table
collect preview
* Export the table to an Excel file
collect export table.xlsx, replace
www.stata.com
Пікірлер: 16
You can read more in our Stata Blog posts "Customizable tables in Stata 17" blog.stata.com/2021/06/07/customizable-tables-in-stata-17-part-1-the-new-table-command/ blog.stata.com/2021/06/07/customizable-tables-in-stata-17-part-2-the-new-collect-command/ blog.stata.com/2021/06/24/customizable-tables-in-stata-17-part-3-the-classic-table-1/ blog.stata.com/2021/08/24/customizable-tables-in-stata-17-part-4-table-of-statistical-tests/ blog.stata.com/2021/08/26/customizable-tables-in-stata-17-part-5-tables-for-one-regression-model/ blog.stata.com/2021/09/02/customizable-tables-in-stata-17-part-6-tables-for-multiple-regression-models/ blog.stata.com/2021/09/08/customizable-tables-in-stata-17-part-7-saving-and-using-custom-styles-and-labels/
Thank you very much Chuck for the great tutorial!
Wow thank you so much 🙏🏼🙏🏼🙏🏼🙏🏼this was very very helpful and useful
Love this video! Thanks
Many thanks!
Thanks for the video! How can I include two more columns with the difference and the p-value?
I have an issue with stata 17, since the version seems not supporting string variables with table command
Thanks for video . How can I make the cells to have n(%)?. I need some help here
How can I make the statistics the columns? I.e. one mean column, one sd column for al specified variables
Thanks for the tutorial. Is it possible to include Pearson's Chi-square and Fisher's exact test P-values?
@statacorp
3 жыл бұрын
Yes, after creating a two-way table with *tabulate* , those values are stored in scalars. You can use the *collect* prefix with *tabulate* to collect those results. Please email us at tech-support@stata.com for an example.
@holybob12
3 жыл бұрын
@@statacorp Thanks for the reply. I'm going to email you for the example. I would want the P-value to be displayed in the last column on the right.
How do we put standard deviation behind mean such that we present= MEAN (SD)?
Stata 17 is awesome
Is it possible that you could present the syntax code as well? thank you!
@statacorp
2 жыл бұрын
webuse nhanes2l, clear * Table of frequencies table () (sex) * Suppress the marginal totals table () (sex), nototals * Add percentages, means, and standard deviations table () (sex), statistic(frequency) statistic(percent) /// statistic(mean age height weight) statistic(sd age height weight) * Format the percentages to one decimal place and display them with a % table () (sex), statistic(frequency) statistic(percent) /// statistic(mean age height weight) statistic(sd age height weight) /// nformat(%9.1f percent) sformat("%s%%" percent) * Format the means and standard deviations to one decimal place table () (sex), statistic(frequency) statistic(percent) /// statistic(mean age height weight) statistic(sd age height weight) /// nformat(%9.1f percent) sformat("%s%%" percent) /// nformat(%9.1f mean) nformat(%9.1f sd) /* Group the results by variable name by placing the variables from the -statistic()- options on the rows */ table (var) (sex), statistic(frequency) statistic(percent) /// statistic(mean age height weight) statistic(sd age height weight) /// nformat(%9.1f percent) sformat("%s%%" percent) /// nformat(%9.1f mean) nformat(%9.1f sd) * Remove the right border collect style cell, border(right, pattern(nil)) * Change the font to arial collect style cell, font(arial) * Preview the table collect preview * Export the table to an Excel file collect export table.xlsx, replace