Home › Forums › ASDOC : Easy Publication Quality Tables in Stata › Combine wide and nest
Tagged: asdoc, asdocx, nested table, Stata, wide table
-
AuthorPosts
-
Berit Rohde
GuestJuly 15, 2020 at 6:39 pmPost count: 118Hello!
I would like to create a table that shows the effect of only one explanatory variable on several outcome variables in different models.
Unfortunately, wide does not allow the keep option and I can´t figure out how to combine wide and nest.
I will give an example:ssc install asdoc, replace sysuse auto, clear *I am only interested in the effect of one explanatory variable (mpg) // 9on two outcome variables (price and trunk) in two different models (with and without headroom) Effect of mpg | in Model 1 in Model 2 ---------------+--------------------------------- on price | ? ? on trunk | ? ? Suggestion on how to combine: asdoc reg price mpg rep78 , nest replace keep(mpg) asdoc reg price mpg rep78 headroom, nest keep(mpg) asdoc reg trunk mpg rep78, wide keep(mpg) asdoc reg trunk mpg rep78 headroom, wide keep(mpg)
I really hope, somebody can help me out!
-
This topic was modified 3 years, 2 months ago by
Attaullah Shah.
This is not possible using the wide and nest options together. However, such customized tables can be easily made with the new asdocx. Here is the code to be used with asdocx
*Add the first header row asdocx addrow, data(Effect of mpg, in Model 1, in Model2) col(1) row(1) *The Regressions reg price mpg rep78 loc mpg1 = _b[mpg] reg price mpg rep78 headroom loc mpg2 = _b[mpg] *Now write the complete row asdocx addrow, data(on price, `mpg1' , `mpg2') col(1) row(2) dec(3) *Another set of regressions reg trunk mpg rep78 loc mpg1 = _b[mpg] reg trunk mpg rep78 headroom loc mpg2 = _b[mpg] *Write another row asdocx addrow, data(on trunk, `mpg1' , `mpg2') col(1) row(3) dec(3) *And then export to Word asdocx export It produces the following output ----+--------------------------------------------- 1 |Effect of mpg in Model 1 in Model2 ----+--------------------------------------------- 2 |on price -271.643 -289.346 3 |on trunk -0.456 -0.303 --------------------------------------------------
Moreover, if this is something you need frequently, you easily create a template file with the above code and use it with asdocx.
-
This reply was modified 3 years, 2 months ago by
Attaullah Shah.
-
This reply was modified 3 years, 2 months ago by
Attaullah Shah.
-
This reply was modified 3 years, 2 months ago by
Attaullah Shah.
-
This reply was modified 3 years, 2 months ago by
Attaullah Shah.
-
This reply was modified 3 years, 2 months ago by
Attaullah Shah.
-
This reply was modified 3 years, 2 months ago by
Attaullah Shah.
-
This reply was modified 3 years, 2 months ago by
Attaullah Shah.
Berit Rohde
GuestJuly 15, 2020 at 8:51 pmPost count: 118Thanks for your quick answer! It is for sure very useful.
Thanks again!-
This reply was modified 3 years, 2 months ago by
Attaullah Shah.
-
This topic was modified 3 years, 2 months ago by
-
AuthorPosts
- You must be logged in to reply to this topic.