Hello everyone!

I am working with unbalanced panel data. I have 18 annual waves (2000-2017) of the survey and I appended them to work on descriptive stats. I created a dummy variable Self for each individual in each wave that takes the value 1 if the individual is self-employed and 0 otherwise. I then appended all the waves. I now want to identify Potential Entrepreneurs. To do that I create a variable PEntr that takes the value 1 if Self was 1 at least in one survey year for an individual (PEntr should be 1 for this individual for all years even though Self was 1 only for one year). I run the following code (Persnr is the individual id and syear is for the survey year)
------------------------
bysort persnr (syear) : gen PEntr = Self[1] ==1 | Self[2]==1 | Self[3]==1 | Self[4]==1 | Self[5]==1 ///
| Self[6]==1 | Self[7]==1 | Self[8]==1 | Self[9]==1 | Self[10]==1 | ///
Self[11]==1 | Self[12]==1 | Self[13]==1 | Self[14]==1 | Self[15]==1 | Self[16]==1 | Self[17]==1 | Self[18]==1

I get the following result

PEntr
Self | 0 1 | Total
-----------+----------------------+----------
0 | 1,242,171 48,420 | 1,290,591
1 | 6,987 72,768 | 79,755
-----------+----------------------+----------
Total | 1,249,158 121,188 | 1,370,346



Now as you can see for 6987 individuals PEntr is 0 although Self is 1.I do not know if the mistake is coming from using the appended data instead of merged data or my code is wrong. I would be thankful if I can get any help on this from the forum.

Thanks a lot.