*# var # Move any set of variables before or after any other variable # help *! 26sep2006 program movel version 8.2 syntax varlist(min=2),[Before Alpha all] opts_exclusive "`before' `all'" if mi("`all'") gettoken fixed moving: varlist else { gettoken first: varlist unab allvars: * local fixed: word `=`:list posof "`first'" in allvars'-1' of `allvars' local moving `varlist' } if mi("`alpha'") order `moving' else { aorder `moving' unab allvars: * local moving: list allvars & moving } foreach v of varlist `moving' { local reversed `v' `reversed' } foreach v of varlist `reversed' { move `v' `fixed' } if ~mi("`before'") move `fixed' `:word 1 of `reversed'' end