Dear friends, I am trying on the stata command, igmobil with upward mobile index using a written program.The code is as below,
Code:
clear
 matrix C = (.25, .5*.25 \ .5*.25, .25)
set seed 12345
drawnorm u0 u1, n(2000) cov(C) /* normal r.v. */

 generate son = exp(u1) /* lognormal r.v.*/
 generate dad = exp(u0)
 generate son_disc = irecode(u1, -1, -0.5, 0, 0.5, 1) /*discrete r.v.*/
 generate dad_disc = irecode(u0, -1, -0.5, 0, 0.5, 1)
 drop u*
 
capture program drop myindex
program myindex, rclass
syntax varlist(min=2 max=2 numeric) [if] [in] [, tau(real 0) s(real 0.25)]
marksample touse
tempvar y x ry rx diff
tempname num den
tokenize ‘varlist’
quietly {
generate ‘y’ = ‘1’ if ‘touse’
generate ‘x’ = ‘2’ if ‘touse’
cumul ‘y’, gen(‘ry’)
cumul ‘x’, gen(‘rx’)
count if (‘ry’-‘rx’) > ‘tau’ & ‘rx’ <= ‘s’ & ‘touse’
scalar ‘num’ = r(N)
count if ‘rx’ <= ‘s’ & ‘touse’
scalar ‘den’ = r(N)
return scalar UW = ‘num’/‘den’
}
end

 igmobil son dad, nosingle noinequal userwritten(myindex son dad, tau(0.1) s(0.25)) classes(4)
It is from the official help file. But it returns some error. I do not understand what the usage of the lines

Code:
marksample touse

tempvar y x ry rx diff
Thank you so much!