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]

From |
Eric Booth <ebooth@ppri.tamu.edu> |

To |
"<statalist@hsphsun2.harvard.edu>" <statalist@hsphsun2.harvard.edu> |

Subject |
Re: st: shifting values one period ahead |

Date |
Wed, 22 Sep 2010 23:35:18 +0000 |

<> On Sep 22, 2010, at 6:19 PM, Eric Booth wrote: >> I am facing a tricky coding issue that involves creating 'newvar1' >> from 'var1' given 'id' and 'start'. The solution I proposed in the previous email creates the 'newvar1', but it does so in relation to 'id', not 'start'. However, I don't see how 'start' impacts the creation of 'newvar1'. For instance, in the second observation and the third observation 'newvar1' gets a 1 because 'var1' in the first and second observation gets a 1, but 'start' is 1 in the first observation and zero in the second observation yet the result for the creation of 'newvar1' is the same because it is based solely upon 'var1' by 'id'. If there is some rule whereby 'newvar1' is created based on both 'id' and 'start', then there needs to be more explanation or clearer example data. On Sep 22, 2010, at 6:19 PM, Eric Booth wrote: > <> > > > bys id : g newvar1 = var1[_n-1] > replace newvar = 0 if mi(newvar1) > > EAB > > __ > Eric A. Booth > Public Policy Research Institute > Texas A&M University > ebooth@ppri.tamu.edu > > > On Sep 22, 2010, at 6:13 PM, asb stata wrote: > >> 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/ > > > > > * > * 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/ * * 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/

**References**:**st: shifting values one period ahead***From:*asb stata <asb.stata@gmail.com>

**Re: st: shifting values one period ahead***From:*Eric Booth <ebooth@ppri.tamu.edu>

- Prev by Date:
**Re: st: shifting values one period ahead** - Next by Date:
**RE: st: RE: RE: estimate precision in MATA** - Previous by thread:
**Re: st: shifting values one period ahead** - Index(es):