capture program drop rmvars program define rmvars, rclass *! 1.1 gmh 8.1.03 syntax varlist, Remove(varlist) di " " unabbrev `varlist' local varlist `"$S_1"' di in gr "variables to examine: " in ye "`varlist'" unabbrev `remove' local remove `"$S_1"' di in gr "variables to remove : " in ye "`remove'" local i = 1 local match = 0 local words : word count `varlist' local rwords : word count `remove' while `i'<=`words' { local j = 1 local check: word `i' of `varlist' while `j' <= `rwords' { local against: word `j' of `remove' if "`check'"=="`against'" { local j = `rwords'+2 local match = `match'+1 * di "matched |`check'| with |`against'|" } local j= `j' +1 } if `j'==`rwords' +1{ local outlist "`outlist' `check'" } local i = `i'+1 } local outlist = trim("`outlist'") di in gr "new variable list : " in ye "`outlist'" di in gr "number of matches : " in ye `match' return local varlist "`outlist'" return scalar matches = `match' end