asdocx: Export from Stata to Word, Excel, LaTeX & HTML › Forums › asdocx Forum › Adding column to table › Reply To: Adding column to table
Hello Rune
Welcome to asdocx forum. I think you need some sort of a customized table, for which flexmat is a good choice. flexmat is part of the asdocx package and it is already installed if you have asdocx. There are several examples where I show how to make tables with flexmat, or modify tables that are already made by asdocx. References to these resources are given below. Please note the option transpose, it changes the table layout from wide to long.
1. Introduction to flexmat : [ view post here ]
2. Add a Stata matrix to existing asdocx table [view post here ]
3. Create tables by cells, rows, or columns [ YouTube Video ]
To give a quick start for your desired solution, let me present the following code:
* Load some example data
sysuse bpwide
* Create statistics with asdocx
asdocx sum bp_before bp_after, stat(count mean sd var p50 skewness) replace transpose
0 |1 2 3
----+-----------------------------------------------------------------------------
1 |Variables bp before bp after
----+-----------------------------------------------------------------------------
2 |N 120 120
3 |Mean 156.45 151.35833
4 |Std. Dev. 11.38985 14.17762
5 |variance 129.72857 201.00497
6 |Median 154.5 149.5
7 |skewness 0.54729 0.38843
----------------------------------------------------------------------------------
* Conduct a two sample t-test
ttest bp_before == bp_after
* The p-value from the t-test can now be appended to row 8 of the table created by asdoc
flexmat addrow, data(p-value, `r(p)') row(8) dec(4)
Table: Summary Statistics
0 |1 2 3
----+-----------------------------------------------------------------------------
1 |Variables bp before bp after
----+-----------------------------------------------------------------------------
2 |N 120 120
3 |Mean 156.45 151.35833
4 |Std. Dev. 11.38985 14.17762
5 |variance 129.72857 201.00497
6 |Median 154.5 149.5
7 |skewness 0.54729 0.38843
8 |p-value 0.0011
----------------------------------------------------------------------------------
* Export the new table to MS Word
asdocx export