This is true -- you can do this -- but the -detail- option
would cause -summarize- to do unnecessary work.
And overwriting existing variables is dubious
practice here.
In general, I think there are at least three good ways
to do this.
1. -center- from SSC, as mentioned.
2.
foreach v of var <varlist> {
qui su `v'
gen z_`v' = (`v' - r(mean)) / r(sd)
}
3.
foreach v of var <varlist> {
egen z_`v' = std(`v')
}
Nick
[email protected]
Masahiko Aida
> You can simply program
>
>
> foreach var of varlist var*{
> quietly: su `var' , de
> replace `var' = (`var' - `r(mean)') / `r(sd)'
> }
Donald Braman
> I need to calculate z-scores for a large number of variables. Does
> anyone have a macro/script for z-score calculations of this sort, or
> know of an ADO that can do it? (I'm relatively new to STATA & miss
> the ease of the z-score function as part of descriptives in SPSS.)
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/