Announcement

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

  • Esttab in the loop

    Dear Stata Users

    I am running multiple time-series regressions and need to output them into the Excel file.

    I am running the following code:
    Code:
    foreach x of varlist RET* HmL* {
            newey `x' mktrf smb hml umd, lag(1) force
    esttab using "T1.csv",  replace cells(b(nostar fmt(2)) t(par([ ])fmt(2)))
    }
        cap erase "T1.txt"
    Unfortunately, Stata records only the last regression output and misses the other 20 outputs. Do you have any idea how to alter this code to correct the error?

    Thanks.

  • #2
    You are writing all of these results to the same file T1.csv, and each time, the earlier contents of that are overwritten by the current regression. That is what the -replace- option does. If you want to put all of these results in a single file, then you need to use the -append- option instead of -replace-. Alternatively, you could save the results of each regression to a separate file. That would mean naming the files in some way reflecting `x' in the loop.

    Comment

    Working...
    X