Hi Experts:
I have a panel data looks like this:
ID employment New Variable
1 1 1
1 1 1
1 1 1
1 2 0
1 2 0
1 1 1
1 2 0
2 1 1
2 1 1
2 2 2
2 2 2
2 2 2
2 2 2
I want to create a new variable that equals to 2 if "2" in the variable employment appears continuously from first time of being observed to the last time of being observed. If the number "2" only appears sporadically, and does not last to the last time of being observed. Then the new variable only records this as "0".
Is there anyone who knows how to code this?
Thank you in advance!
Connie
I have a panel data looks like this:
ID employment New Variable
1 1 1
1 1 1
1 1 1
1 2 0
1 2 0
1 1 1
1 2 0
2 1 1
2 1 1
2 2 2
2 2 2
2 2 2
2 2 2
I want to create a new variable that equals to 2 if "2" in the variable employment appears continuously from first time of being observed to the last time of being observed. If the number "2" only appears sporadically, and does not last to the last time of being observed. Then the new variable only records this as "0".
Is there anyone who knows how to code this?
Thank you in advance!
Connie
Comment