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 on April 23, and its replacement, statalist.org is already up and running.


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

RE: st: FW: How to keep only firms that have at least two consecutive years of data


From   umut senalp <uerksan@hotmail.com>
To   <statalist@hsphsun2.harvard.edu>
Subject   RE: st: FW: How to keep only firms that have at least two consecutive years of data
Date   Thu, 5 Jul 2012 17:56:02 +0300

Dear Anees,
Thank you for your reply, the thing is, all firms have 9 consecutive years of observation for the 5 variables but with missing. What I am trying to do is to keep only firms have observation for all the variables and have it at least two consecutive years. When I follow this
 xtset id year
> bys id: gen nyear=[_N]
> keep if nyear>1 ,         this does not drop any observation at all, since all id's have 9 years data for the variables. 
Thanks, 
Umut
----------------------------------------
> Date: Thu, 5 Jul 2012 19:13:16 +0500
> Subject: Re: st: FW: How to keep only firms that have at least two consecutive years of data
> From: anees@aneconomist.com
> To: statalist@hsphsun2.harvard.edu
>
> Check this might help you.
>
> xtset id year
> bys id: gen nyear=[_N]
> keep if nyear>1
>
> Hope this works.
> Anees
>
>
> On Thu, Jul 5, 2012 at 7:04 PM, umut senalp <uerksan@hotmail.com> wrote:
> >
> > Dear Statalist,
> > I have a panel of 1250 units (firms) and five variables (with missing values), for the time period of 2003 to 2011. I would like to keep only firms that have a minimum of 2 consecutive annual observations for all variables together. I would be glad if you could help me to write a code for it.
> > Regards
> > Umut
> > *
> > * 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/
>
>
>
> --
>
> Best
> ---------------------------
> Muhammad Anees
> Assistant Professor/Programme Coordinator
> COMSATS Institute of Information Technology
> Attock 43600, Pakistan
> http://www.aneconomist.com
>
> *
> * 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/


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