Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: disregarding duplicate observations in a variable list


From   "Jessica Looze" <[email protected]>
To   [email protected]
Subject   st: disregarding duplicate observations in a variable list
Date   Tue, 6 Jan 2009 21:37:37 -0500

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, .)
}




© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index