[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: Code erroring out because of "no observations"

From   Scott Merryman <>
Subject   Re: st: Code erroring out because of "no observations"
Date   Thu, 25 Jun 2009 16:06:59 -0500

Perhaps, something like this:

webuse nlswork, clear

sort idcode year
bysort idcode: egen wave = seq()

tsset idcode wave

gen pred_wave =.
logit union age collgrad tenure hours if wave==1

predict pred if e(sample)
replace pred_wave = pred
drop pred

levelsof wave if wave >1, local(levels)
foreach i of local levels {
	qui {
		logit  union  l.ln_wage l.age l.collgrad l.tenure l.hours if wave==`i'
		predict pred if wave == `i'
		replace pred_wave= pred if wave == `i'
		drop pred

keep pred wave idc
reshape wide pred, j(wave) i(idco)
egen predfinal = rowmax( pred*)

*   For searches and help try:

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