Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: foreach and postfile


From   Simon Moore <[email protected]>
To   [email protected]
Subject   st: foreach and postfile
Date   Thu, 13 Dec 2007 10:33:21 +0000

I have a question which I think I already know the answer to (I'm sure I've seen this asked on Statalist before but can't find the post).

I'm running something along the lines of:-

postfile coef id var1 var2 var3 using "`dir'\fit.dta", replace
foreach num of numlist 1(1)1000 {
qui logit expcont var1 var2 var3 if id == `num'
post coef (`num') (_b[var1]) (_b[var2]) (_b[var3])
}
postclose coef

occasionally the logit does not work as planned, gives an error (e.g. "[var] not found") and the foreach loop grinds to a halt. I would much rather capture the error somehow, post it to the file coef and have the loop move onto the next iteration. Would anyone here happen to have encountered a similar problem and worked out a solution?

Regards
Simon

*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/




© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index