Announcement

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

  • Create an Excel table using outreg2

    Hi, I have a problem with the outreg2-command. The requirement is that I have to create an Excel table to incorporate all results obtained from the two loops below in 1 table. The loops are as follows:
    eststo clear

    foreach var in budget_health budget_defense {
    eststo: xi: reg `var' q1_to_q1 `Controls'
    }
    outreg2-command using 2a, excel nocons

    foreach var in budget_health budget_defense {
    eststo: xi: reg `var' q1_to_q5 `Controls'
    }
    outreg2-command using 2a, excel nocons

    I have tried to add outreg2 at the end of each command but it does not work. For example, with the 1st loop, it only records the results of budget_health with q1_to_q1 on the table, without the result of budget_defense. Same as for the second loop. Can anyone help me with this issue? Thank you so much!

  • #2
    Hi Trang,

    You may need to add "append" option in outreg2 command within your loop (outreg2 is from SSC). Something like
    Code:
    sysuse auto, clear
    foreach var in price foreign {
        qui reg `var' length weight, robust
            outreg2 using "2a.xls", append nocons
    }
    Hope this helps.
    Last edited by Dung Le; 14 Jun 2023, 00:54.

    Comment

    Working...
    X