Announcement

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

  • ourteg2, addtable

    WHy does my second table rewrite over my first table instead when I use this command?

  • #2
    Dear Harshada,

    When you extract the second regression table consequent to the first one (I am presuming that you want to place two regressions side by side in a single file since you have not provided the exact code although I request you to provide code when you post a question next time), just add ",append" in the outreg2 command. By default it takes "replace" and thus it is replacing your first table. You could also read the help file on outreg2.

    Best,
    Disha

    Comment


    • #3
      Thanks Disha, this is the code I am using right now.


      xtreg `lhs1' `rhs' `controls', fe robust cluster(store)
      outreg using `file1', replace landscape nocons var keep(`rhs') store(Table6A)

      xtreg `lhs1' `rhs1' `controls', fe robust cluster(store)
      outreg using `file1', merge nocons var keep (`rhs1') ctitle("",All stores)


      **lhs2**

      xtreg `lhs2' `rhs' `controls', fe robust cluster(store)
      outreg using `file1', replay (Table6A) addtable landscape nocons var keep (`rhs') store(Table6B)


      xtreg `lhs2' `rhs1' `controls', fe robust cluster(store)
      outreg using `file1', merge (Table6B) landscape nocons var ctitle(All stores) keep (`rhs1')
      ex

      Comment


      • #4
        Thanks for sharing the code Harshada.

        Let me give you an example of placing tables from two regressions, one beside the other. You might want to try the following:

        xtreg y x1 x2, fe robust
        outreg2 using filename.xls, ctitle() replace

        xtreg y x1 x2 x3, fe robust
        outreg2 using filename.xls, ctitle() append

        Using the above you would be able to get the two tables in same file.

        Comment


        • #5
          Disha, that code adds an extra column to the same Table, it doesn't create a new table below the first table

          Comment


          • #6
            First of all, outreg and outreg2 are two different commands. Your title specifies outreg2 but none of what you are trying to do will work with outreg2. Presumably you are using John Gallup's outreg from stata journal. Outreg has been updated a number of times so use -which outreg- to confirm you have the most recent version, which I believe is version 4.24 from dec 2012.

            Second, please read the FAQ on how best to structure questions so that we can easily help you. Pay particular attention to the request to provide sample data using dataex. Since you didn't do that I can't easily test code that will work for your specific models. Instead here is some sample code that shows the general idea.

            Code:
            use http://www.stata-press.com/data/r14/auto.dta, clear
            
            reg mpg weight foreign 
            outreg , store(t1)
            
            
            reg mpg weight foreign gear_ratio
            outreg using f1 , merge(t1) 
            
            
            reg price mpg foreign
            outreg ,  store(t2)
            
            
            reg price mpg foreign gear_ratio
            outreg using f1 , merge(t2) addtable replace
            The main thing to observe here is that you do not specify using and the file name every time, only when you've finished a table and want to write it. I find outreg kind of hard to use for writing multiple tables and it often takes some trial and error to make sure I put all the options in the right places. This example should help you get started.

            Comment


            • #7
              Hi Sarah,

              That code produces a file that has Table 1 and then Table 1 again with an additional column that has the results for the last estimation from table 2. Any thoughts?

              Comment


              • #8
                The code I provided above works for me. It generates two tables. The first table contains two models with mpg as the outcome. The second table contains two models with price as the outcome. If you are getting something different you should show what you typed and the resulting Stata output. You should also note what version of Stata you are using and the results of which outreg.

                My code was checked using Stata version 14.2. It would surprise me if that radically changed the behavior of outreg, but it is possible I suppose.



                Comment


                • #9
                  Sarah! It worked, I had forgotten to change outreg to outreg2 in the last line. That was the problem. Thank you so much.

                  Comment

                  Working...
                  X