Dear sir, madam,
I have a question regarding certain data management challenges that would allow me to perform a survival analysis using panel data from the Panel Study of Income Dynamics. I am analyzing the period leading up to the decision for an individual to become an entrepreneur.
To be able to perform a survival analysis (to stset the data) I need to create a spell length variable which I want to do on the basis of the data available to me. The commands that I have been using are as follows:
generate BusStart = 0
bysort ID (year): replace BusStart=1 if (BusOwn[_n]==1 & BusOwn[_n-1]==0)
BusOwn is a dummy variable that equals 1 if an individual owns a business at year n. My aim is to only analyse the first business start of any individual. The commands that I have been using however create a dummy that is 1 whenever a person owns a business in period n after not having owned a business in period n-1. Therefor it is possible that a single person has more than one period where BusStart == 1, and indeed it does occur.
Is there an easy way to create a dummy variable (BusStart) that only equals 1 at time n if all previous periods of BusOwn equal zero?
Thanks in advance.
Kind regards,
Joel
I have a question regarding certain data management challenges that would allow me to perform a survival analysis using panel data from the Panel Study of Income Dynamics. I am analyzing the period leading up to the decision for an individual to become an entrepreneur.
To be able to perform a survival analysis (to stset the data) I need to create a spell length variable which I want to do on the basis of the data available to me. The commands that I have been using are as follows:
generate BusStart = 0
bysort ID (year): replace BusStart=1 if (BusOwn[_n]==1 & BusOwn[_n-1]==0)
BusOwn is a dummy variable that equals 1 if an individual owns a business at year n. My aim is to only analyse the first business start of any individual. The commands that I have been using however create a dummy that is 1 whenever a person owns a business in period n after not having owned a business in period n-1. Therefor it is possible that a single person has more than one period where BusStart == 1, and indeed it does occur.
ID | BusStart | BusOwn | year |
5170 | 1 | 1 | 1996 |
5170 | 0 | 1 | 1997 |
5170 | 0 | 0 | 1999 |
5170 | 1 | 1 | 2001 |
5170 | 0 | 0 | 2003 |
ID | BusStart | BusOwn | year |
5170 | 1 | 1 | 1996 |
5170 | 0 | 1 | 1997 |
5170 | 0 | 0 | 1999 |
5170 | 0 | 1 | 2001 |
5170 | 0 | 0 | 2003 |
Thanks in advance.
Kind regards,
Joel
Comment