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: Re: st: drop variables with missing values


From   "Braunfels, Philipp (Stud. SBE / Alumni)" <P.Braunfels@student.maastrichtuniversity.nl>
To   "statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu>
Subject   Re: Re: st: drop variables with missing values
Date   Fri, 27 Jul 2012 15:27:28 +0200

Thanks so much it works!
(ps. there was a type with "del", i.e. instead of -de l=max- it is -del=max-)



On Fri, Jul 27, 2012 at 12:26 PM, San Chu <bichsan@yahoo.com> wrote:
> 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)" <P.Braunfels@student.maastrichtuniversity.nl>
> To: "statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu>
> 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) <P.Braunfels@student.maastrichtuniversity.nl> 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?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/

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