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.
Related Posts with Generating a dummy variable that takes the value 1 if another dummy takes the value 1 at least once in longitudinal data
Using esttab and estout to Flip Models and Coefficients (tffects nnmatch coefs)Hi Stata ninjas, I am using estout documentation to develop a table that includes the coefficients …
How to zoom in a part of the kdensity graph?Hi, I would like to zoom in the left tail of a kdensity graph. I would like to show clearly the dif…
. . …
Testing the null hypothesis that the skewness/kurtosis of 2 times series variable are the sameHi, I would like to test the null hypothesis that the skewness/kurtosis of 2 times series variable …
Independent sample t-testDear researchers, I have unbalanced panel data for a set of firms. In 2002 a new standard has been i…
Subscribe to:
Post Comments (Atom)
0 Response to Generating a dummy variable that takes the value 1 if another dummy takes the value 1 at least once in longitudinal data
Post a Comment