Customizable tables in Stata 17: One-way tables of summary statistics

Поделиться
HTML-код
  • Опубликовано: 10 май 2021
  • 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
    @statacorp  3 года назад +1

    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 Год назад +1

    Thank you very much Chuck for the great tutorial!

  • @anne-marieturcotte-trembla3630
    @anne-marieturcotte-trembla3630 2 года назад

    Love this video! Thanks

  • @Jlaloca21
    @Jlaloca21 2 года назад +1

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

  • @sabrinerk3210
    @sabrinerk3210 Год назад

    Many thanks!

  • @MultiKasuku
    @MultiKasuku 2 года назад +1

    Stata 17 is awesome

  • @andresramasco5644
    @andresramasco5644 Год назад

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

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

  • @gabrielfranceschini2823
    @gabrielfranceschini2823 Год назад

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

  • @holybob12
    @holybob12 3 года назад

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

    • @statacorp
      @statacorp  3 года назад +1

      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 года назад +1

      @@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
    @kuldeepmirdha8452 3 года назад +3

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

  • @iirou
    @iirou 2 года назад

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

    • @statacorp
      @statacorp  2 года назад +3

      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