I don't know how to solve a problem with my long panel data set. This is an example of the data.
Code:
clear
input float(id income eventtime)
101 . -3
101 30 -2
101 30 -1
101 30 0
101 30 1
101 30 2
101 30 3
101 30 4
101 30 5
102 . -3
102 40 -2
102 . -1
102 40 0
102 40 1
102 40 2
102 40 3
102 40 4
102 . 5
102 . 6
103 . -3
103 . -2
103 . -1
103 . 0
103 50 1
103 50 2
103 50 3
103 50 4
103 50 5
103 50 6
end
I need to keep the id observations where income is non-missing at least 5 times, and non-missing income at least once before the event and at least once after the event.
Hence, id 101 and id 102 should be kept (or all observations with id==103 should be dropped).

So far I have this:

Code:
generate t = .
replace t = 1 if eventtime < 0
replace t = 2 if eventtime == 0
replace t = 3 if eventtime > 0

bysort id t: egen countbef = total(income!=.) if t==1
bysort id t: egen countaft = total(income!=.) if t==3
However, I don't know where to go from here. Could you help me?