Using flexmat inside asdocx – append column to summary statistics


The flexmat program can be used both outside and inside asdocx (in this example, we shall use it inside asdocx). When it is used inside asdocx, we shall skip the keyword flexmat and just pass on the flexmat’s sub-command. In the following example, we shall add a column to an existing table using the sub-command addmat. The sub-command addmat belongs to flexmat program, with the matname() option specifying the matrix name which we want to add to the existing table. We shall also use the right option, that specifies to append the matrix / column to the left of the existing table. To explore more about flexmat, you can type help flexmat in the Stata command window.

 

* Load example data
webuse grunfeld, clear

* Create descriptive statistics with asdocx
asdocx sum invest mvalue kstock , replace

 sktest invest mvalue kstock

* Store the results matrix
mat table = r(table)

* Get the p-value column
mat pvalue =  table[....,5...]

* Add the pvalue column to the summary statistics at column 7
asdocx addmat, matname(pvalue) right dec(3)

* Change the column title p_chi2
asdocx addcell, data(p-value) col(7)

asdocx addmat flexmat