Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: How to tell a macro to use previous global value of that loop, akin to [_n-1] for columns


From   "Eva Poen" <eva.poen@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: How to tell a macro to use previous global value of that loop, akin to [_n-1] for columns
Date   Sun, 17 Aug 2008 14:06:37 +0100

I should add that this solution does not cater for two or more
consecutive entries and exits by the same firm within the 10 year
timeframe. So, if cases like this one exist,

1 1 . . 1 1 1 1 . .  (first exit in year 2, then re-entry in year 4
and exit in year 8)

only the last exit will be recorded.

Eva


2008/8/17 Eva Poen <eva.poen@gmail.com>:

> gen ExitYear = .
> forvalues X = 2/10 {
>               replace ExitYear= `X'-1 if LHS_NMCE_`X'==. & LHS_NMCE_`=`X'-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   |   What's new   |   Site index