I use tokenize in Stata 14.2. For more information see manuals13/ptokenize
HTML Code:
https://www.stata.com/manuals13/ptokenize.pdf
Code:
cap: program drop substi program define substi syntax varlist [if] [in] marksample touse, novarlist tokenize `varlist', p(" ") di `1' di `2' di `3' replace `1'=`2' if `touse' replace `1'=`3' if `touse'==0 end gen a = uniform() gen b = uniform() gen c = uniform() gen d = uniform() substi a b c if d>0.5
Comment