0
votes

I have a bunch of datasets in the same folder and I would like to run the very same regression for every dataset. Also, I would like to export the respective regression output in .tex format for every dataset. This is what I tried:

ssc inst fs, replace
fs *.dta 
foreach f in `r(files)' {
use "`f'" 
local newname : subinstr local f ".dta" ".tex"
reghdfe y x1 x2 x3, absorb(fe1 fe2) cluster(fe1 fe2)
outreg2 using `newname', replace ctitle ((1)) addtext(fe1, YES, fe2, YES) adjr2
}

I get the error invalid 'Export'. The regression is run, but it seems the outreg2 is not working. I don't see my mistake, who can help?

2

2 Answers

0
votes

I see two weird things here

  • should not you use use f, replace?
  • is outreg2 compatible with reghdfe?
0
votes

Wild guess: the command beginning

outreg2 using `newname' 

should begin

outreg2 using "`newname'"

if any filename in question includes any spaces. See [U] 11.6 in the Stata manuals.