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
filling missing valuesDear All, I find this question here (in Chinese). The raw data is Code: * Example generated by -da…
Random effect logistic regressionHi everyone I have recently started to use Stata, and confused about how I should interpret the res…
Seemingly unrelated regression (sureg) & Testing for significant differences of a coefficient across more than two equationsI will use sureg (seemingly unrelated regression) to analyze my data. I need to test my coefficients…
Difference-in-Difference, with IVHello everyone, I would like to ask one question that I am struggling on. I would like to estimate …
checking the imputed valuesHi all, I have watched a video by chuck huber about multiple imputation. i want to know how to check…
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