[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

From |
Kit Baum <[email protected]> |

To |
[email protected] |

Subject |
st: re: centering variables |

Date |
Tue, 7 Dec 2004 08:32:06 -0500 |

It is not clear whether Naceur has one variable with chunks belonging to each country ("long" format, in which Uli's solution with by country, sort: egen xbar = mean(xi) would work well) or six variables named x_1 - x_6 ("wide" format). Assuming the latter:

forval i=1/6 {

summ x_`i'. meanonly

qui replace x_`i' = x`i' - r(mean)

}

If a new set of variables are desired, the second line in the loop could be

qui gen xc_`i' = x_`i' - r(mean)

Kit Baum, Boston College Economics

http://ideas.repec.org/e/pba1.html

On Dec 7, 2004, at 2:33 AM, Naceur wrote:

First, I have a variable x_i for each six country (i = 1,...,6) and I want to calculate the difference x_i - xbar_i. Or the xbar_i is the mean of the variable of x_i for each country. Did you have an idea about the command that I should do?

Kit Baum, Boston College Economics http://ideas.repec.org/e/pba1.html * * 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/

**Follow-Ups**:**Re: st: re: centering variables***From:*"Mark Schaffer" <[email protected]>

- Prev by Date:
**Re: st: saving files with replace** - Next by Date:
**st: heckprob or biprob and getting lamda terms** - Previous by thread:
**st: saving files with replace** - Next by thread:
**Re: st: re: centering variables** - Index(es):

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