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

st: Re: centering


From   Kit Baum <[email protected]>
To   [email protected]
Subject   st: Re: centering
Date   Tue, 7 Dec 2004 07:39:55 -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?
*
*   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