Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at

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

Re: st: Addressing variables

From   Maarten Buis <[email protected]>
To   [email protected]
Subject   Re: st: Addressing variables
Date   Wed, 14 Sep 2011 17:31:57 +0200

--- 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 L. Buis
Institut fuer Soziologie
Universitaet Tuebingen
Wilhelmstrasse 36
72074 Tuebingen
*   For searches and help try:

© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index