Create a balanced panel in Stata #stata #panel
local panel_length 7
tempvar panel
egen panel=count(1), by(ID)
gen balance=1 if panel==`panel_length'
// or
local panel_length 7
tempvar q
bysort id: gen `q' = _n
gen byte balanced = 0
replace balanced = 1 if `q'==`panel_length'
// or
local panel_length 7
bysort id: gen balanced = (_N >= `panel_length')
source: http://www.stata.com/statalist/archive/2008-03/msg01110.html