*! version 1.0 15oct2024

Title

sumdocx -- Generate comprehensive summary statistics and comparison tables in Word

Syntax

sumdocx varlist [if] [in] [, options]

Main
by(varname) perform two-group comparison

title(string) specify title for the table

save(string) specify filename to save the Word document

threshold(#) set p-value threshold for significance (default is set at 0.05)

decimals(#) set number of decimal places (default is set at 2 decimal places)

font(string) specify font for the table (default is set to match your system settings)

size(#) specify font size for the table (default is set as size 8)

color(string) specify color for the header row (default is set as a shade of blue)

Description

sumdocx creates comprehensive summary statistics tables in Microsoft Word format with just a single line of code. It offers two main functionalities:

1. Single-variable summaries: For each numerical variable, sumdocx provides a rich set of statistics including the number of observations (N), mean, median, minimum, maximum, percentage of observations at the minimum and maximum values, and the count of missing values. This comprehensive overview allows researchers to quickly understand the distribution and key characteristics of their variables.

2. Two-group comparisons: When using the by() option, sumdocx provides summary statistics similar to balance tables for comparing two groups. It presents the number of observations and means for both groups, calculates the difference in means, performs a t-test (assuming unequal variances between groups), and reports the p-value. This feature is useful for assessing balance in randomized controlled trials, comparing treatment and control groups, or any scenario where you need to contrast two subsets of your data (like pre-tests and post-tests).

sumdocx is designed to handle multiple variables with different sample sizes (rather than reducing all the variables included in the command to a common subset), making it robust for real-world datasets with missing values. Its output is directly formatted for reports, hopefully saving researchers, international organizations and iNGOs time and effort. With customizable options for fonts, colors, and decimal places, tables produced by sumdocx can be immediately incorporated into papers, presentations, or reports.

This command requires Stata version 15 or higher due to its use of the putdocx command.

This command filters out string variables to allow users to use the wildcard * and summarize all numerical variables in the dataset. The ignored string variables are displayed as part of the output.

Options

Main

by(varname) specifies a binary variable for two-group comparison. If specified, the program will perform t-tests between the two groups for each variable.

title(string) adds a title to the output table.

save(string) specifies the filename to save the Word document. If not specified, sumdocx can be used as part of a longer putdocx based report.

threshold(#) sets the p-value threshold for determining statistical significance in two-group comparisons. The default is set at 0.05.

decimals(#) sets the number of decimal places for numeric output. The default is set at 2.

font(string) specifies the font to be used in the table. If not specified, the default font (as per your system settings - most likely, Aptos) is used.

size(#) specifies the font size to be used in the table. Default font size is 8.

color(string) specifies the color for the first row of the table. The default is "1F497D" (my preferred shade of blue).

Examples

sysuse auto.dta, clear

Basic use:

sumdocx price weight mpg, save(auto)

Using the by option:

sumdocx price weight mpg, by(foreign) save(auto_foreign)

Using a higher threshold for the p-value and adding a table title:

sumdocx *, by(foreign) threshold(0.01) title("Auto Performance by Car Origin Status") save(auto_foreign2)

Additional customization:

sumdocx *, decimals(3) font("Calibri Light") size(9) color(FFA500) save(auto_customization)

More customization:

sumdocx *, by(foreign) font("Garamond") size(8.5) color(navy) save(more_customization)

Author

Kabira Namit, World Bank, knamit@worldbank.org

Acknowledgments

Special thanks to Zaeen de Souza, Ketki Samel and Prabhmeet Kaur for testing and reviewing sumdocx.