Title
ttable -- Mean Comparison for a lot of variables between two groups with formatted table output
Syntax
ttable syntax varlist(min=1) [if] [in], by(varname),
varlist is a list of numerical variables to be tested. For each of those variables, we need to perform a standard t-test to compare her mean difference between two groups specified by by(varname)
varname must be a dichotomous variable for the sample specified by [if] and [in]. varname maybe either numerical or string, provided that it only takes two different values for the sample.
A Simulated Examples
clear set obs 1000
forval i = 1(1) 10 { gen x`i' = `i'+uniform()*`i' } gen num_d = uniform()>0.2+x1*.3+x2*.4-x3*.5 gen xs = string(uniform())+"A" gen str_d = "A" replace str_d = "B" if x1<1.400 ttable x1, by(num_d)
ttable x1 xs, by(num_d)
ttable x1-x10, by(num_d)
ttable x1-x10, by(num_d)
ttable x1-x10 xs, by(str_d) ttable x1-x10 in 1/800, by(str_d) ttable x1-x10 in 1/800 if x1<1.8, by(str_d)
After Test Users can copy the output from Stata's result window, then paste to a MS word document. After that, highlight the pasted words and transform into a table.
Authors
Xuan Zhang Zhongnan University of Economics and Law Wuhan, China zhangx@znufe.edu.cn
Chuntao Li Zhongnan University of Economics and Law Wuhan, China chtl@znufe.edu.cn