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

Re: st: Automatic mean-centering?

From   "Sarah A. Mustillo" <[email protected]>
To   [email protected]
Subject   Re: st: Automatic mean-centering?
Date   Wed, 25 Aug 2004 15:34:45 -0400

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*


Clive Nicholas wrote:


I'm interested in re-running old models by mean-centering all my
continuous variables for comparison, as well as obtaining meaningful
intercept values. At the same time, I wish to include dummy variables
which, for obvious reasons, would not be mean-centered.

Now I know how to do this manually, as we all do:

. gen splodge = spludge-100

where 100 is the mean of SPLUDGE. But I'm interested to know if there's a
quicker way, especially if I have a _lot_ of continuous variables to

Having explored the help files for -xi- and Mitchell and Ender's -xi3-
(which IS downloadable via SSC, unlike -renvars-!), neither routine
automatically creates mean-centered variables. Searching -findit- _and_
the archive turned up nothing and nothing relevant respectively.

If anyone has any ideas, I'd be keen to hear them. Ta!

CLIVE NICHOLAS        |t: 0(044)191 222 5969
Politics              |e: [email protected]
Newcastle University  |
*   For searches and help try:

Sarah A. Mustillo, Ph.D
Department of Psychiatry and Behavioral Sciences
Duke University School of Medicine
Box 3454
Durham NC 27710

919 687-4686 x231
*   For searches and help try:

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