Announcement

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

  • For loop: Possibility to append columns to the right in a table

    Hello,

    I have several dependent variables and am running a loop. The goal is to save the regression results in a LaTeX table. I need in this table to have the dependent variables d20_07_19 d30_07_19 d40_07_19 d50_07_19 d60_07_19 as headers in each column. For example:
    d20_07_19 d30_07_19 d40_07_19 d50_07_19 d60_07_19
    The problem is that in the way I run the loop I get tables appended one after the other. For example, first comes the result for d20_07_19. If I manually create the table as I need it, it will take me a lot of time. Do you know a way to produce the result I need in STATA? Below I attach the loop as I run it.

    foreach y of varlist d20_07_19 d30_07_19 d40_07_19 d50_07_19 d60_07_19 {

    eststo TR1_6_`y' : cgmreg `y' a b c d e f i.dcode, cluster(ccode dcode)

    esttab TR1* using output_.1.tex, append b(3) se(3) ar2(3) ///
    se star(^{*} 0.1 ^{**} 0.05 ^{***} 0.01) title(OLS regression estimates)
    eststo clear
    }
    Last edited by Iva Mihaylova; 04 Aug 2021, 00:04.

  • #2
    I found the following easy and fast solution:

    Since the append option of esttab does not allow to append columns to the right / horizontally, I do the following

    export via esttab in .csv format, reformat in Excel the Table in the way I need it and then export it to LaTeX

    Comment


    • #3
      estout is from the Stata Journal/ SSC, as you are asked to explain (FAQ Advice #12).

      foreach y of varlist d20_07_19 d30_07_19 d40_07_19 d50_07_19 d60_07_19 {

      eststo TR1_6_`y' : cgmreg `y' a b c d e f i.dcode, cluster(ccode dcode)

      esttab TR1* using output_.1.tex, append b(3) se(3) ar2(3) ///
      se star(^{*} 0.1 ^{**} 0.05 ^{***} 0.01) title(OLS regression estimates)
      eststo clear
      }
      You have an existing table and you want to add estimates. You can do one of three things:

      1) overwrite the existing estimates using the -replace- option

      2) append estimates underneath using the -append- option

      3) add the estimates to existing estimates (specifying neither -append- nor -replace-)


      If #3, you're undercutting yourself by adding the -append- option.

      Comment


      • #4
        Originally posted by Andrew Musau View Post
        estout is from the Stata Journal/ SSC, as you are asked to explain (FAQ Advice #12).



        You have an existing table and you want to add estimates. You can do one of three things:

        1) overwrite the existing estimates using the -replace- option

        2) append estimates underneath using the -append- option

        3) add the estimates to existing estimates (specifying neither -append- nor -replace-)


        If #3, you're undercutting yourself by adding the -append- option.
        Thank you!

        Comment

        Working...
        X