-------------------------------------------------------------------------------
help for tabexport
-------------------------------------------------------------------------------

Export tables of summary statistics to text files

tabexport varlist [if exp] [in range] [weight] using filename , statistics(statistics_list) [ list(list_options) format(format(s)) by(varlist) cw total noreshape variableorder outfile out_options ]

Any weights are allowed, except as indicated by help on collapse.

Description

tabexport exports as tables to text files various arrays of summary statistics which could be created by using collapse. By default outsheet is used, but optionally outfile may be specified. The results are also listed to provide a check on what is produced.

Options

statistics() is a required option. One or more statistic names as specified in the help for collapse should be used. Note that each statistic will be calculated for each variable: collapse itself is not so restrictive.

format() specifies one or more numeric formats controlling the detail of each statistic produced. The sequence of formats is that of the sequence of statistics. Thus with s(count mean) f(%9.0f %9.1f) counts will be shown with format %9.0f and means with format %9.1f. If fewer formats are specified than there are statistics, the last-specified format will be repeated for all remaining statistics. Thus with s(count mean sd) f(%9.0f %9.1f) counts will be shown with format %9.0f and means and sds with format %9.1f. See help on format.

list() specifies options of list to tune the output listing.

by(byvarlist) and cw are the corresponding options of collapse.

total applies whenever by() is also specified and specifies that results should be appended for all of the observations specified. Such results will be listed separately, as a reflection of the production process, but they will be combined in the resulting file.

noreshape specifies that files produced should have a wide data structure, with many columns (variables). The default is that they should be reshaped to have a long data structure, with fewer columns.

variableorder may be specified with noreshape. The default of noreshape is that of collapse: the variable order is by statistic, then by original variable. variableorder reverses this: the variable order is by original variable, then by statistic.

outfile specifies that outfile should be used to export files. The default is to use outsheet.

out_options are options of outsheet or (if the outfile option is specified) of outfile. By default, noquote is specified.

Examples

. sysuse auto, clear . tabexport turn trunk length using results.txt, s(mean sd) by(foreign) . tabexport turn trunk length using results.txt, s(mean sd) by(foreign) total replace . tabexport turn trunk length using results.txt, s(mean sd) by(foreign) total replace format(%9.1f) . type results.txt

Author

Nicholas J. Cox, Durham University, U.K. n.j.cox@durham.ac.uk

Acknowledgements

Raymond Guiteras suggested this problem. Kit Baum provided some helpful field testing, identified an ordering problem and suggested the format() option. Fred Wolfe suggested adding a handle for list and identified another ordering problem.

Also see

On-line: help for tabstat