capture program drop within
program define within

* version 8.0
 syntax varlist [if]

foreach var of local varlist {
* capture drop `var'_*
capture egen `var'_idot=mean(`var') `if', by(`1')
capture g `var'_WD=`var'-`var'_idot
* drop `var'_idot

}

drop `1'_idot `1'_WD

end

**************************************************************
* COMMAND: within name_individuals list_of_variables  condition
* it creates the within transformation in order to estimate fixed effects model
* with any command different from xtreg, fe
* it is suitable for create transformation within-individuals and also within-time