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
xttrans2 - calculating transitional probabilities for multiple years.Hi, I'm a little confused with regards to the xttrans2 command and obtaining transitional probabilit…
graph that shows the evolution over 10 yearsHi guys, We have drawn 10 individual histograms for working hours from 2004 to 2013 in Belgium. No…
merging survey data files - duplicate data problemDear All, I am working on two survey datasets and have encountered the same problem in the small da…
Combine roc curvesI have two ROC curves each one is derived from a totally different model and interested in combining…
Categorical Bar Chart (Binary Variables) with Multiple VariablesHi Users, Another graphing question. I have a list of 8 adoption barriers in which survey responden…
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