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

  • @statacorp
    @statacorp3 жыл бұрын

    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/

  • @yileizhang2237
    @yileizhang2237 Жыл бұрын

    Thank you very much Chuck for the great tutorial!

  • @Jlaloca21
    @Jlaloca212 жыл бұрын

    Wow thank you so much 🙏🏼🙏🏼🙏🏼🙏🏼this was very very helpful and useful

  • @anne-marieturcotte-trembla3630
    @anne-marieturcotte-trembla36302 жыл бұрын

    Love this video! Thanks

  • @sabrinerk3210
    @sabrinerk3210 Жыл бұрын

    Many thanks!

  • @andresramasco5644
    @andresramasco5644 Жыл бұрын

    Thanks for the video! How can I include two more columns with the difference and the p-value?

  • @gabrielfranceschini2823
    @gabrielfranceschini2823 Жыл бұрын

    I have an issue with stata 17, since the version seems not supporting string variables with table command

  • @kalibbaladennis
    @kalibbaladennis Жыл бұрын

    Thanks for video . How can I make the cells to have n(%)?. I need some help here

  • @HxCWW
    @HxCWW Жыл бұрын

    How can I make the statistics the columns? I.e. one mean column, one sd column for al specified variables

  • @holybob12
    @holybob123 жыл бұрын

    Thanks for the tutorial. Is it possible to include Pearson's Chi-square and Fisher's exact test P-values?

  • @statacorp

    @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

    @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.

  • @kuldeepmirdha8452
    @kuldeepmirdha84523 жыл бұрын

    How do we put standard deviation behind mean such that we present= MEAN (SD)?

  • @MultiKasuku
    @MultiKasuku2 жыл бұрын

    Stata 17 is awesome

  • @iirou
    @iirou2 жыл бұрын

    Is it possible that you could present the syntax code as well? thank you!

  • @statacorp

    @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

Келесі