Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Estout puts table horizontally instead of vertical

    I am trying to export stata output to excel using the estout package.
    Installing was no problem but when running the following code my tables are put in a horizontally manner in excel (see screenshot)
    Is there any way to get these results in a vertical table?
    Code:
    forv i = 0(1)36{
    qui reg MSCI_BHAR if month ==`i'
    eststo reg`i'
    }
    
    esttab using example.csv, replace
    Click image for larger version

Name:	screentshot.png
Views:	1
Size:	96.3 KB
ID:	1347667

  • #2
    if you run esttab after every regression the result would be each table placed after the other in a vertical fashion. see example.csv here:
    Code:
    sysuse auto
    foreach var of varlist weight mpg {
        reg price `var'
        esttab using example.csv, append
    }
    If that's not what you want, maybe this is what you want:
    http://repec.org/bocode/e/estout/adv...ml#advanced907

    Comment


    • #3
      Hi,

      My question is exactly the opposite: I would want the results in a horizontal table, in a word/rtf output. When using the following code, it ranges each output one under the other:


      Code:
        reg y x ,robust
        est store ols1
      esttab using ols1.rtf, se nodepvars  replace 
      
      
        reg y x ,robust
        est store ols2
      esttab using ols1.rtf, se nodepvars append

      How could I get est to range the output horizontally in the same table?

      Comment


      • #4
        Just store all the regressions and then run esttab once on the stored models.
        Esttab defaults to outputing the latest run regression if you don't specifiy what exactly to output. Thus you need to either specify directly what stored estimates you wish to output, or use _all to output all stored estimations.

        Also, you can use eststo instead of est store. use help eststo to learn more.
        Code:
        reg y x, robust
        est store ols1
        
        reg y x1, robust
        est store ols2
        
        esttab ols1 ols2 using ols.rtf
        Code:
        reg y x, robust
        est store ols1
        
        reg y x1, robust
        est store ols2
        
        esttab _all using ols.rtf

        Comment


        • #5
          Thanks Ariel!

          Comment


          • #6
            Hi, I have the exact same question as Feodora Bayles but in addition, I also have different fixed effects scalars to be displayed for each model. They are mostly different for each model.

            Currently, my code is:

            eststo reg1: areg depvar indepvars, ab(id) cl(id)
            quietly estadd scalar N1 = e(N)/2, replace
            quietly estadd local f1 "Yes", replace
            quietly estadd local f2 "No", replace

            eststo reg2: areg depvar indepvars, ab(id) cl(id)
            quietly estadd scalar N2 = e(N)/2, replace

            #delimit ;
            esttab reg1 reg2 using table6.rtf,
            varwidth(25)
            stats(f2 f2 f1 f2 N N1 r2_a, fmt(0 0 0 0 0 0 3) label("Individual Characteristics" "lala" "School FE" "Individual FE" "Number of Observations" "Number of students" "Adj. R-Square")) noobs
            b(%9.3f) se(%9.3f) nomtitles
            nobaselevels addnotes(Note: This table shows the results of Columns 1, 2, 3 and 4 of Table 5.*significant at 10% ** 5% and *** 1%.)
            nonotes unstack replace;
            #delimit cr

            Now for different models, you will note that N1 and N2 will be different. So will the yes and no to the FE categories. How to add different options for each reg1 and reg2?

            Kindly guide.

            Comment


            • #7
              Each model usually has its own N (no. of observations), R-squared, etc., and that works out fine. Therefore, what is needed is consistency.

              quietly estadd scalar N1 = e(N)/2, replace
              quietly estadd scalar N2 = e(N)/2, replace
              If you define N1 as half the number of observations in one model, there is no reason to define it as N2 in another model. Leave it as N1. Same idea for the locals.

              quietly estadd local f1 "Yes", replace
              quietly estadd local f2 "No", replace
              So you specify each stat only once (as you have done with N and r2_a).

              Code:
              stats(f2 f1 N N1 r2_a)
              Finally, instead of adding scalars, look at the -indicate- option of estout for indicating the presence of fixed effects.

              Comment

              Working...
              X