Bookmark and Share

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]

Re: st: drop variables with missing values


From   San Chu <[email protected]>
To   "[email protected]" <[email protected]>
Subject   Re: st: drop variables with missing values
Date   Fri, 27 Jul 2012 03:26:03 -0700 (PDT)

Hi Philipp,
Please try this:
 
sort ID Time
by ID : gen gap = 0 
by ID : replace gap = 1 if (_n>1) & missing(Return) & !missing(Return[_n-1])
by ID : egen de l= max(gap)
drop if del == 1
drop gap del

Best regards,
San
________________________________
From: "Braunfels, Philipp (Stud. SBE / Alumni)" <[email protected]>
To: "[email protected]" <[email protected]> 
Sent: Thursday, July 26, 2012 2:42 PM
Subject: Re: st: drop variables with missing values

In addition to my last mail:
maybe it is helpful to visualize the "delete gap" problem (I want to delete those observations for which I do not have consecutive "return" values! - in order to apply newey west!)

ID   Return   Time
1      3%          01/2000
1      4%          02/2000
1      5%          03/2000
1      6%          04/2000
1      7%          05/2000

2      20%        01/2000
2      21%        02/2000
2       .             03/2000
2      22%        04/2000
2      23%        05/2000

3      .              01/2000
3      .              02/2000
3      12%        03/2000
3      13%        04/2000        
3      14%        05/2000


This means, the comopany with ID 2 should be deleted but not the one with 3 or 1! (sorry if I mixed up variables and observations in my prior email!)






On Thu, Jul 26, 2012 at 9:27 PM, Braunfels, Philipp (Stud. SBE / Alumni) <[email protected]> wrote:
> Dear statlisters,
> I am asking for your advice on the following issue: I want to run a newey-west regression (to account for heteroscedasticity and autocorrelation). I have a panel of 2000 companies and their respective returns. however the returns of some companies have missing values aka "gaps". Therefore, I would like to delete all companies that have gaps in order to apply newey west. In this respect, I have also companies that have consecutive data but start at a later year than my sample (e.g. company values as of 2006 but sample starts in 2000). for the latter companies I would like to retain all values (as this should not be a problem with the newey west estimation?!?!).
>
> usually I would just write - drop if return>=. -  however this would also eliminate those companies for which I have consecutive data (but start at a later date than my overall sample)
>
> I am very thankful for any advice!
>
> greets!
> *
> *   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?searchhttp://www.stata.com/support/statalist/faqhttp://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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index