I would like to thank Howie Lempel, Martin Weiss and Scott Merryman for
their responses to my question. My code runs like a charm using any of the
three methods proposed!
Date: Thu, 25 Jun 2009 16:44:26 -0400
From: Howard Lempel <[email protected]>
Subject: st: RE: Code erroring out because of "no observations"
Hi Ariel,
In your loop, _N represents the number of total observations, not the total
number of waves. There are only 15 waves of data, so when i gets to 16, you
get an error - there are no observations for which wave==16.
I think you want to change your loop to the following:
forvalues i=2/15 {
logit union l.ln_wage l.age l.collgrad l.tenure l.hours if wave==`i'
predict pred`i' if wave == `i'
}
If you don't want to stick 15 in as a magic number, you could to the
following:
sum wave
local max = r(max)
forvalues i=2/`max' {
logit union l.ln_wage l.age l.collgrad l.tenure l.hours if wave==`i'
predict pred`i' if wave == `i'
}
Hope this helps.
Howie
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/