Hi all,
I am trying to create a variable that indicates the number of jobs an
individual has held during a period of years. The dataset I am using,
NLSY97, records each respondents' work history in a roster format.
This roster assigns each job a unique ID indicating the year the job
began. For example, the roster for respondent #1 might look like:
ID Year Job 1 Job2 Job3
1 1997 9701 9702 9703
1 1998 9801 9701 .
So, during these two years, this respondent held four different jobs
(9701 extending over into 1998).
My data looks something like this:
ID EMP1_97 EMP2_97 EMP3_97 EMP1_98 EMP2_98 EMP3_98
1 9701 9702 9703 9801
9701 .
2 9701 . . 9701
. .
I have been working with the row operations suggested in the egenmore
help entry. My current working code looks like that on this manual
page:
gen any = 0
gen all = 1
gen count = 0
foreach v of varlist emp1_97 emp2_97 emp3_97 emp1_98 emp2_98 emp3_98 {
replace any = max(any, inrange(`v', 0, .))
replace all = min(all, inrange(`v', 0, .))
replace count = count + inrange(`v', 0, .)
}