Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: Automatic mean-centering?

From   Nick Winter <>
Subject   Re: st: Automatic mean-centering?
Date   Wed, 25 Aug 2004 16:48:45 -0400

At 03:34 PM 8/25/2004 -0400, you wrote:
You are probably looking for something more automated or sophisticated, but I usually do something like this:

foreach var in x x1 x2 x3 x4 x5 x6 x7 x8...x100{
egen temp`var'=mean(`var')
gen c`var'=`var'-temp`var'

drop temp*

You can avoid generating a new variable here:

foreach var in x x1 x2 {
sum `var' , meanonly
gen c`var' = `var'-r(mean)

(the meanonly option both suppresses output from the -summarize-, and speeds it up by not calculating the variance)

--Nick Winter

Nicholas Winter 607.255.8819 t
Assistant Professor 607.255.4530 f
Department of Government e
308 White Hall w
Cornell University
Ithaca, NY 14853-4601

* For searches and help try:

© Copyright 1996–2015 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index