*! version 1.7.2 3apr2019

Title

xtsum2docx -- Report summary statistics of panel data to a formatted table in the DOCX format.

Syntax

xtsum2docx varlist [if] [in] using filename [, options]

where varlist is a list of numerical variables.

Description

xtsum2docx can report all statistics that can be reported by xtsum and by summarize with the option detail.

This is an extension of the user-written command sum2docx (instead of a wrapper, so sum2docx is not required to be installed).

xtsum2docx has an additional feature to re-order the resulting table columns using the option order(). The names of statistics (e.g., mean, xtn, etc.) should be listed in the order that you would like.

Options: added to xtsum2docx

order(string) lists the outputs in the specified order in the resulting table.

xtn[(fmt)] outputs the number of panels (i.e., r(n)) and specifies the format.

xttbar[(fmt)] outputs the average T (i.e., r(Tbar)) and specifies the format.

xtmaxb[(fmt)] outputs the between-maximum (i.e., r(max_b)) and specifies the format.

xtmaxw[(fmt)] outputs the within-maximum (i.e., r(max_w)) and specifies the format.

xtminb[(fmt)] outputs the between-minimum (i.e., r(min_b)) and specifies the format.

xtminw[(fmt)] outputs the within-minimum (i.e., r(min_w)) and specifies the format.

xtsdb[(fmt)] outputs the between-standard deviation (i.e., r(sd_b)) and specifies the format.

xtsdw[(fmt)] outputs the within-standard deviation (i.e., r(sd_w)) and specifies the format.

Options: inherited from sum2docx

replace permits to overwrite an existing file.

append permits to append the output to an existing file.

title(string) specifies the title of the table.

obs[(fmt)] outputs the number of the observations and specifies the format.

mean[(fmt)] outputs the mean and specifies the format.

var[(fmt)] outputs the variance and specifies the format.

sd[(fmt)] outputs the standard deviation and specifies the format.

skewness[(fmt)] outputs the skewness and specifies the format.

kurtosis[(fmt)] outputs the kurtosis and specifies the format.

sum[(fmt)] outputs the sum and specifies the format.

min[(fmt)] outputs the minimum and specifies the format.

median[(fmt)] outputs the median and specifies the format.

max[(fmt)] outputs the maximum and specifies the format.

p1[(fmt)] outputs the 1st percentile and specifies the format.

p5[(fmt)] outputs the 5th percentile and specifies the format.

p10[(fmt)] outputs the 10th percentile and specifies the format.

p25[(fmt)] outputs the 25th percentile and specifies the format.

p50[(fmt)] outputs the 50th percentile (i.e., the median) and specifies the format.

p75[(fmt)] outputs the 75th percentile and specifies the format.

p90[(fmt)] outputs the 90th percentile and specifies the format.

p95[(fmt)] outputs the 95th percentile and specifies the format.

p99[(fmt)] outputs the 99th percentile and specifies the format.

Examples

`"webuse abdata.dta, clear"'

Report summary statistics for variable n, w, and k, saving the table as "temp.docx":

`"xtsum2docx n w k using temp.docx, replace obs mean sd p25 p50 p75 xtn xttbar title("Summary statistics")"'

Re-order the statistics, with additional formatting (some statistics are now reported in %9.2f):

`"xtsum2docx n w k using temp.docx, replace obs mean(%9.2f) sd(%9.2f) p25 p50 p75 xtn xttbar(%9.2f) order(p25 p50 p75 mean sd xtbar xtn obs) title("Summary statistics")"'

Append another table (a feature inherited from sum2docx):

`"xtsum2docx n w k using temp.docx, append xtminw xtmaxw xtsdw(%9.2f) xtminb xtmaxb xtsdb(%9.2f) order(xtminw xtmaxw xtsdw xtminb xtmaxb xtsdb) title("Additional statistics")"'

Acknowledgment

I am so grateful to the original authors of sum2docx, Chuntao Li (China Stata Club) and Yuan Xue (China Stata Club), for developing such a nice command. I also thank Li Tang (IMF) for her kind and very helpful support. I am deeply thankful to Professor Christopher F. Baum to maintain the Statistical Software Components (SSC) archive, hosted by Boston College (United States).

Author

Futoshi Narita

International Monetary Fund

Washington, DC, United States

fnarita@imf.org