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

Re: st: re: centering variables


From   "Mark Schaffer" <[email protected]>
To   [email protected]
Subject   Re: st: re: centering variables
Date   Tue, 07 Dec 2004 13:49:50 -0000

Have a look at Ben Jann's -center- command.

--Mark

To:             	[email protected]
From:           	Kit Baum <[email protected]>
Subject:        	st: re: centering variables
Date sent:      	Tue, 7 Dec 2004 08:32:06 -0500
Send reply to:  	[email protected]

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

Prof. Mark E. Schaffer
Director
Centre for Economic Reform and Transformation
Department of Economics
School of Management & Languages
Heriot-Watt University, Edinburgh EH14 4AS  UK
44-131-451-3494 direct
44-131-451-3008 fax
44-131-451-3485 CERT administrator
http://www.som.hw.ac.uk/cert

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