Statalist


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

Re: st: keeping dates which are n periods apart


From   "Scott Merryman" <scott.merryman@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: keeping dates which are n periods apart
Date   Sun, 18 May 2008 20:49:46 -0500

Does this work?

clear
input id year

        4   1987
        4   1988
        4   1989
        4   1990
        4   1992
        4   1993
        4   1994
        9   1986
        9   1987
        9   1988
        9   1989
        9   1990
        9   1992
        9   1993
        9   1994
        9   1995
        9   1996
        9   1997
end

bysort id (year): gen tag = 1 if _n ==1
bysort id (year): replace tag = 1 if  mod(year, 3) ==1 & tag == . &
tag[_n-1] != 1
keep if tag ==1
drop tag
l, sepby(id)


Scott




On Sun, May 18, 2008 at 8:02 PM, Rajesh Tharyan <R.Tharyan@exeter.ac.uk> wrote:
> Hi all,
>
> I have this ( a subset of the original dataset, the original dataset has
> about 6000 ids with an  average of 6 years each)
>
>    id   year
>     4   1987
>     4   1988
>     4   1989
>     4   1990
>     4   1992
>     4   1993
>     4   1994
>     9   1987
>     9   1988
>     9   1989
>     9   1990
>     9   1992
>     9   1993
>     9   1994
>
> I need to keep years if they are more than 2 years apart by company.
*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index