*! version 2.1 12Dec2025

Title

tab2excel -- Export tabstat results to Excel with enhanced features

Syntax

tab2excel varlist [if exp] [in range] [,
options]

options

Main
language(string) output language, either "chinese" or "english"

filename(string) output Excel filename

title(string) title for the Excel sheet

replace replace existing Excel file

statistics(string) statistics to export, e.g., "n mean sd min max"

Description

tab2excel exports descriptive statistics from tabstat to an Excel file with enhanced formatting features.
The command provides bilingual support (Chinese/English) and automatically formats statistics with appropriate number formats.

Key features:

• Bilingual output (Chinese/English) with automatic header translation

• Excel hyperlink output for easy file access

• Variable labels support in Excel

• Automatic number formatting (integers for counts, 2 decimals for other stats)

• Professional Excel formatting with borders and bold headers

Options

Main

language(string) specifies the output language. Valid values are "chinese" (default) and "english".
When set to "chinese", column headers and titles are displayed in Chinese. When set to "english",
they appear in English.

filename(string) specifies the output Excel filename. Default is "summary.xlsx".

title(string) specifies the title for the Excel sheet. If not specified, a default title
is used based on the selected language: "描述性统计" for Chinese or "Descriptive Statistics" for English.

replace allows overwriting an existing Excel file. If this option is not specified and
the file already exists, the command will return an error.

statistics(string) specifies which statistics to export. The string should contain
statistic names separated by spaces. Available statistics include:

n - Number of observations

mean - Mean

sd - Standard deviation

var - Variance

cv - Coefficient of variation

sem - Standard error of the mean

skew - Skewness

kurt - Kurtosis

sum - Sum

p1 - 1st percentile

p5 - 5th percentile

p10 - 10th percentile

p25 - 25th percentile

p50 - Median (50th percentile)

p75 - 75th percentile

p90 - 90th percentile

p95 - 95th percentile

p99 - 99th percentile

min - Minimum

max - Maximum

iqr - Interquartile range

range - Range

Default is n mean p25 p50 p75 min max.

Examples

Example 1: Basic usage with default options

. sysuse auto, clear

. tab2excel price mpg weight

Example 2: Custom statistics with Chinese output

. sysuse auto, clear

. tab2excel price mpg weight, language(chinese) statistics(n mean sd skew kurt min max) title("汽车数据统计摘要") filename("car_stats.xlsx") replace

Example 3: English output with custom title

. sysuse auto, clear

. tab2excel price mpg weight, language(english) statistics(n mean p25 p50 p75) title("Automobile Data Summary") filename("auto_summary.xlsx") replace

Example 4: Using if condition

. sysuse auto, clear

. tab2excel price mpg weight if foreign == 1, language(english) filename("foreign_cars.xlsx") replace

Authors

Wu Lianghai, Liu Rui, Li Min, School of Business, Anhui University of Technology(AHUT) Ma'anshan, China

agd2010@yeah.net

3221241855@qq.com

748726942@qq.com

Wu Hanyan, School of Economics and Management, Nanjing University of Aeronautics and Astronautics(NUAA) Nanjing, China

2325476320@qq.com

Wu Xinzhuo, University of Bristol(UB)

2957833979@qq.com

Development date: 12 December 2025

Also see

Online: tabstat, tabstat2excel, putexcel