Home Forums ASDOC : Easy Publication Quality Tables in Stata Combine the outputs of a t-test plus a summarize using asdoc Reply To: Combine the outputs of a t-test plus a summarize using asdoc

The mistake you are making is the declaration of the Age text as a macro, by enclosing it in the macro symbols. In fact, Age is just a text, it is not declared as a local macro with the loc command. The correct is given below.

```clear
set obs 100
gen mean_age = int(uniform() * 100)
gen stupd = mod(_n,2)

ttest mean_age, by(stupd)

*Get the relevant statistics

loc obs1 = `r(N_1)'
loc obs2 = `r(N_2)'
loc mean1 = `r(mu_1)'
loc mean2 = `r(mu_2)'
loc dif = `mean1' - `mean2'
loc stde = `r(se)'
loc pval = `r(p)'
dis `dif'

sum mean_age if stupd == 0
loc max1 = `r(max)'
loc min1 = `r(min)'

sum mean_age if stupd == 1
loc max2 = `r(max)'
loc min2 = `r(min)'

*Write these with asdoc using the row option

asdoc, row(Age, `obs1', `obs2', `min1', `max1', `min2', `max2', `mean1', `mean2', `dif', `stde', `pval') replace```