Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

AW: st: Addressing variables


From   "Christopher Garlich" <cgarlich@mail.uni-mannheim.de>
To   <statalist@hsphsun2.harvard.edu>
Subject   AW: st: Addressing variables
Date   Wed, 14 Sep 2011 17:36:51 +0200

..clunky, but working!
Thanks a lot!!

Cheers,
chris

--- On Wed, Sep 14, 2011 at 5:12 PM, Christopher Garlich wrote:
> yes, this is kind of what I want. But "i" in my case is a variable, and
for
> each row I want "i" to take on the value that it has in that specific row.

I don't think there is an easy way of doing so. A clunky way would be
the following (assuming that the maximum value of i = 5):

gen temp = .
forvalues i = 1/5 {
   drop temp
    egen temp = rowmean(Lag1 - Lag`i')
    replace avg = temp if i == `i'
}

Hope this helps,
Maarten

--------------------------
Maarten L. Buis
Institut fuer Soziologie
Universitaet Tuebingen
Wilhelmstrasse 36
72074 Tuebingen
Germany


http://www.maartenbuis.nl
--------------------------
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index