Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
st: creating lagged variables
From
"[email protected]" <[email protected]>
To
"[email protected]" <[email protected]>
Subject
st: creating lagged variables
Date
Sat, 10 Aug 2013 17:13:59 +0000
Dear Stata list users,
I have a multilevel dataset where I have individual survey responses collected at different time points( waves but different years), and country level data.Some countries are in all waves, some are only in some of them.
I would like to generate a lagged independent variable. I would like to take an average of its values at t-1, t-2 and t-3 where t denotes a year when there was a survey study for a particular country.
I don't know what command to use in stata for 'at' or 'when' .
.by country year: egen meanlaggedx=3D mean(x(at time-1) x(at time-2) x(at time-3)) is pretty much what I am trying to do, but to no avail. How do I specify a variable a certain time point?
For some reason the usual lag command does not respond in my dataset.
I appreciate any help or suggestion.
Thanks,
Sule
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/faqs/resources/statalist-faq/
* http://www.ats.ucla.edu/stat/stata/