Here is one solution that is not messed up by
any missings:
reshape long w_job, i(ID) j(jobnum)
bysort ID (w_job): ///
gen Number_job = cond(w_job < ., jobnum, jobnum[_n-1])
by ID : replace Number_job = Number_job[_N]
reshape wide w_job, i(ID) j(jobnum)
This still leaves yet another problem: if two or more
jobs tie for maximum wage, then only one of them is recorded.
Nick
[email protected]
*
* 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/