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

st: creating lag variables


From   Reka Sundaram-Stukel <[email protected]>
To   [email protected]
Subject   st: creating lag variables
Date   Mon, 5 May 2003 00:27:14 -0500

Dear Statalist,

I am trying to create a lag y for data that looks like the following:

id type choice Year lag_choice
1 a 1 1 -
1 b 0 1 -
1 c 0 1 -
1 d 0 1 -
1 a 0 2 1
1 b 0 2 0
1 c 1 2 0
1 d 0 2 0

how do I generate lag_choice. I have tried

by id type: gen lag_choice=choice[_n-1] and various combinations of this quite unsuccessfully. Help please

Thanks in advance

Reka


Reka Sundaram-Stukel
Graduate student
320 Taylor Hall
Department of Agriculture And Applied Economics
Madison, WI-53706


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