Hi, Nick Cox (no relation - or i might be better at stats!) helped someone else with a similar query but i could not adapt his code to work.
I write in STATA 13:
local varlist "hypro-arg"
foreach var in `varlist' {
sum `var'
}
Above works all fine.
Then i want to generate a set of standardised variables from the same varlist and i write:
local varlist "hypro-arg"
foreach var in `varlist' {
egen z_`var' =std(`var')
}
but it does not work .. Why??
Nick wrote a solution to a similar problem that looked like this:
foreach v of var <varlist> { > egen mean_`v' = mean(`v') > egen sd_`v' = sd(`v') > } Thanks anyone for helping - i am sure it is annoyingly obvious!
I write in STATA 13:
local varlist "hypro-arg"
foreach var in `varlist' {
sum `var'
}
Above works all fine.
Then i want to generate a set of standardised variables from the same varlist and i write:
local varlist "hypro-arg"
foreach var in `varlist' {
egen z_`var' =std(`var')
}
but it does not work .. Why??
Nick wrote a solution to a similar problem that looked like this:
foreach v of var <varlist> { > egen mean_`v' = mean(`v') > egen sd_`v' = sd(`v') > } Thanks anyone for helping - i am sure it is annoyingly obvious!
Comment