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: Replace with missing value


From   André Gyllenram <[email protected]>
To   "[email protected]" <[email protected]>
Subject   RE: st: Replace with missing value
Date   Fri, 12 Apr 2013 15:18:52 +0200

Thank you for your help! This worked!

Regards
André


----------------------------------------
> Date: Fri, 12 Apr 2013 13:44:15 +0100
> Subject: Re: st: Replace with missing value
> From: [email protected]
> To: [email protected]
>
> I thought your original question was clear; you just asked a different
> question.
>
> Before getting to an answer, I recommend _strongly_ against holding
> daily dates as integers such as 20000101. This causes at least two
> problems: you need to worry about precision and you get hiatuses in
> the data such as that between 20001231 and 20010101. This will bite
> you, hard, sooner or later, so I recommend that you convert to Stata
> daily dates. Then use date functions such as -year()- to work with
> years.
>
> I'll rephrase what appears to be your basic question. You are, or
> should be, calculating variances
>
> by <id> <year> : egen var = var(<response>)
>
> but you want to overwrite variances with missing if any values
> considered are missing. That could be
>
> by <id> <year> : egen nmissing = total(missing(<response>))
>
> replace var = . if nmissing
>
> Nick
> [email protected]
>
>
> On 12 April 2013 13:10, André Gyllenram <[email protected]> wrote:
>
> > Thank you for your answer. But i realized that i was not very clear in my first post. Sorry about that.
> >
> > What i want to do is that i want to compute the variance for different periods and stocks. The problem I have is that stata does not consider missing values when computing the variance.
> >
> > If i write the code:
> >
> > by isin: egen variance20001230=var(price) if datum>=20000101 & datum< 2000123
> > 0
> >
> > this gives me the 1-year variance for every stock between 200010101 and 20001230. However it does not consider missing values. If i have any missing values in the price -data for any stock in the time period 20000101-20001230 i want to set the variace for that stock equal to missing.
> >
> > Maybe this problem is easier to solve?
>
> *
> * For searches and help try:
> * http://www.stata.com/help.cgi?search
> * http://www.stata.com/support/faqs/resources/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/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index