Hello I have data in the following format:
Personid lfs_1 lfs_2 lfs_3
0203 1 . .
3333 . 1 0
note: lfs, lfs_1 and lfs_2 are dummy variables that are in different time periods. lfs indicates if individual is in the labor force or not across time.
I want the data to be in the following format:
Personid Period lfs
0203 1 1
3333 2 1
3333 3 0
Notice here I want to do 2 things:
Firstly:
Generate a column called period. Period =1 if the lfs_1 column is not null. Period= 2 if lfs_1 column is not null. Period=3 if lfs_2 is not null.
Secondly:
Given that some indiviuals might have non null values in 2 or more lfs columns (like the person with id=3333). I want my data to be in long format where person id is duplicated (replicated) if a person has observation in multiple time periods.
Personid lfs_1 lfs_2 lfs_3
0203 1 . .
3333 . 1 0
note: lfs, lfs_1 and lfs_2 are dummy variables that are in different time periods. lfs indicates if individual is in the labor force or not across time.
I want the data to be in the following format:
Personid Period lfs
0203 1 1
3333 2 1
3333 3 0
Notice here I want to do 2 things:
Firstly:
Generate a column called period. Period =1 if the lfs_1 column is not null. Period= 2 if lfs_1 column is not null. Period=3 if lfs_2 is not null.
Secondly:
Given that some indiviuals might have non null values in 2 or more lfs columns (like the person with id=3333). I want my data to be in long format where person id is duplicated (replicated) if a person has observation in multiple time periods.
Comment