Bookmark and Share

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: shifting values one period ahead


From   asb stata <[email protected]>
To   [email protected]
Subject   st: shifting values one period ahead
Date   Wed, 22 Sep 2010 19:13:22 -0400

I am facing a tricky coding issue that involves creating 'newvar1'
from 'var1' given 'id' and 'start'. The variable 'newvar1' is obtained
by shifting 'var1' one period ahead within each 'id'.

id	start	var1	newvar1

1	1	1	0
1	0	1	1
1	0	0	1
1	0	0	0

2	0	0	0
2	0	0	0
2	1	1	0
2	0	0	1
2	0	1	0

3	0	0	0
3	0	0	0
3	1	1	0
3	0	1	1
3	0	1	1
*
*   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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index