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
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
0 Response to dropping observations by id with multiple if conditions
Post a Comment