Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: Re: statalist-digest V4 #1066

From   Yan elaine Li <liy@Stanford.EDU>
Subject   st: Re: statalist-digest V4 #1066
Date   Thu, 14 Nov 2002 02:22:42 -0800 (PST)

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!


*   For searches and help try:

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