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

From |
Roberto <terrymondo@onetel.net.uk> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
st: Data manipulation: how to keep only consecutive obs in an unbalanced panel |

Date |
Mon, 11 Oct 2004 13:35:16 +0100 |

Dear Statalist friends

I am currently trying to run a GMM estimation using the xtabond2 command.

I have an unbalanced panel so I would want to manipulate my dataset in a way that Stata only keeps the continuous observations for each firm

For example consider these 3 firms

code name year run maxrun _spell _seq _end n N

135540 A 1995 1 5 1 1 1 1 6

135540 A 1997 1 5 2 1 0 2 6

135540 A 1998 2 5 2 2 0 3 6

135540 A 1999 3 5 2 3 0 4 6

135540 A 2000 4 5 2 4 0 5 6

135540 A 2001 5 5 2 5 1 6 6

900327 B 1991 1 7 1 1 0 1 10

900327 B 1992 2 7 1 2 0 2 10

900327 B 1993 3 7 1 3 1 3 10

900327 B 1995 1 7 2 1 0 4 10

900327 B 1996 2 7 2 2 0 5 10

900327 B 1997 3 7 2 3 0 6 10

900327 B 1998 4 7 2 4 0 7 10

900327 B 1999 5 7 2 5 0 8 10

900327 B 2000 6 7 2 6 0 9 10

900327 B 2001 7 7 2 7 1 10 10

134982 C 1997 1 1 1 1 1 1 3

134982 C 1999 1 1 2 1 1 2 3

134982 C 2001 1 1 3 1 1 3 3

with the tsspell command I have been able to identify the maximum number of consecutive observations per firms.

The problem is that if I write

keep if maxrun>=5

stata only drops firm "C" whereas I would want it to drop all the non-consecutive observations in all panels so that the database would look like:

code name year

135540 A 1997

135540 A 1998

135540 A 1999

135540 A 2000

135540 A 2001

900327 B 1995

900327 B 1996

900327 B 1997

900327 B 1998

900327 B 1999

900327 B 2000

900327 B 2001

Can anyone help?

Thank you all for the kind attention.

Best Regards

Roberto Mura

PhD candidate

University of York

*

* 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/

- Prev by Date:
**Re: st: using Stata's micombine command on a SAS-imputed dataset** - Next by Date:
**st: Re: ST: one-tailed test** - Previous by thread:
**st: Question about reg3/ivreg--endogeneity issue** - Next by thread:
**st: Re: ST: one-tailed test** - Index(es):

© Copyright 1996–2014 StataCorp LP | Terms of use | Privacy | Contact us | What's new | Site index |