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 at the end of May, and its replacement, statalist.org is already up and running.


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

st: shifting values one period ahead


From   asb stata <asb.stata@gmail.com>
To   statalist@hsphsun2.harvard.edu
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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index