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

Re: st: Automatic mean-centering?


From   Nick Winter <[email protected]>
To   [email protected]
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*

Sarah
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 [email protected] e
308 White Hall falcon.arts.cornell.edu/nw53 w
Cornell University
Ithaca, NY 14853-4601

*
* 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/




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