Home Forums ASDOC : Easy Publication Quality Tables in Stata Restart nested table in asdoc and append mean Reply To: Restart nested table in asdoc and append mean

Attaullah Shah
Keymaster
Post count: 69

Alreena
You can use the reset option for starting a new table. See the following example
*Example Make a nested table of 3 regressions

sysuse auto, clear
*First regression
asdoc reg price mpg rep78, nest replace

*Add variable headroom and then nest with existing table
asdoc reg price mpg rep78 headroom, nest 

*Add variable weight and then nest with existing table		
asdoc reg price mpg rep78 headroom weight, nest 

*Start a new table, note option reset

*First regression
asdoc reg price mpg rep78, nest reset

*Add variable headroom and then nest with existing table
asdoc reg price mpg rep78 headroom, nest 
asdoc reg price mpg rep78 headroom weight, nest 

asdoc reset option to start a new table in the same file


Add additional Statistics to nested table


You can use the add() option to add additional text or statistics to the nested table. In the following code, I first get the mean of the dependent variable using the sum command and write it to the local mean. Then pass on this info to the nested table using the add(Mean,mean’)` option.

*First find mean of the dependent variable

qui sum price
local mean = `r(mean)'
asdoc reg price mpg rep78, nest reset add(Mean, `mean')

*Second regression use turn as the dependent variable
qui sum turn
local mean = `r(mean)'
asdoc reg turn mpg rep78 headroom, nest add(Mean, `mean')

Add mean of the dependent variable to nested table of asdoc