I am looping through multiple datasets and creating a matrix of regression coefficients using each dataset. I'm running into a conformability error when running the command: esttab est*. However, the error occurs on the second iteration of the loop, regardless of how I order the datasets. If I run them each individually, I don't have this error. I'm trying to clear everything at the start of the loop, but this makes me think that I'm not doing so successfully. If I stop the loop without the last line of code, it runs fine (I don't know why). Here is part of the code (that has an error when run). I realize I'm not saving anything here, again, because this is only part of my code. Do you know where there may be an error?
Code:
set more off foreach st in al ar { clear * use `st'_full, clear *run regressions, storing coefficients set more off eststo clear levelsof id, local(levels) levelsof id, local(col_names) foreach unt of local levels { capture eststo: reg arnma fb fb_lag i.hour i.month i.day if id=="`unt'" if _rc ~= 0 { local not `unt' local col_names: list col_names- not } } *create coefficient matrix, save as variables pause esttab est* pause mat c= r(coefs) foreach unt of local col_names { local names "`names' coef`unt' tval`unt' pval`unt'" } mat colnames c =`names' }
Comment