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
 How does the PPML command check for overfitting?Dear all,
I have a question about the procedure how the PPML command is checking for overfitting. I… How does the PPML command check for overfitting?Dear all,
I have a question about the procedure how the PPML command is checking for overfitting. I…
 Python 3.8, error r(7100)I have been trying out the latest release of Python, 3.8.0, but when I try to use it I get the follo… Python 3.8, error r(7100)I have been trying out the latest release of Python, 3.8.0, but when I try to use it I get the follo…
 Robust standard errors - OLS - Right-skewed distributionHi,
I am looking at data for returns of companies after their initial public offering. The return-d… Robust standard errors - OLS - Right-skewed distributionHi,
I am looking at data for returns of companies after their initial public offering. The return-d…
 Identifier with huge codesHallo everybody and thanks in advance for any kind of suggestion.
I am working on a large dataset ab… Identifier with huge codesHallo everybody and thanks in advance for any kind of suggestion.
I am working on a large dataset ab…
 Mata compiler ignores eltypes / orgtypes for variable declarationsHi,
I was surprised to see that the Mata compiler seems to ignore much of the eltype and orgtype sp… Mata compiler ignores eltypes / orgtypes for variable declarationsHi,
I was surprised to see that the Mata compiler seems to ignore much of the eltype and orgtype sp…
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