hi statalisters,
I would like to get help on the following problem:
i have a life history dataset on job mobility, where for each
observation i have the following variables:
job01 start01 end01 indstr01 income01 ... job12 - income12 ...
where 'start01' means the starting year and 'end01' means the
ending year of the first job.
I also have a variable 'yrmar' (year married), and my task is to
find out what job a person had when s/he got married and how
much they earn from that job and so on.
I tried the following code and it obviously doesn't work when
you have a variable named "start01" instead of "start1":
gen jobmar=.
gen incmar=.
forvalues i=01(1)12 {
if (yrmar >= start`i' & yrmar<= end`i') {
replace jobmar=job`i'
replace incmar=income`i'
}
}
I guess the central question is how to loop using strings/chars
rather than number.
any help would be greatly appreciated!
Yan
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/