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 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.

* Create descriptive statiscis 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)

asdocx addmat flexmat