Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.

# Re: st: Counting number of observations in the following 4 years

 From Nick Cox To "statalist@hsphsun2.harvard.edu" Subject Re: st: Counting number of observations in the following 4 years Date Thu, 20 Feb 2014 00:46:59 +0000

```I don't understand what this means. I guess that "keep" means -keep-,
or inversely not  -drop-.

Suppose X is present in years 1,2,3,4,5,6,7,8 but not in 9,10. So I
keep observations in years 1 to 4 because everything in year 5 to 8 is
OK. But now I don't keep 5 or 6 or 7 or 8 because 9 and 10 are
missing. But that means the decisions for earlier observations should
now be revisited, and I end up dropping everything.

In general, if you have missing values in time series you can just
-drop- the missing values and/or let Stata do its best. The two are
usually equivalent. Anything else is likely to mean just losing
information capriciously and unnecessarily. .

Nick
njcoxstata@gmail.com

On 20 February 2014 00:24, micdepo mic <micdepo@gmail.com> wrote:
> Hi,
>
> I have data on variable X for a period of time. I am trying to count
> for every given year t the number of future observations on X in the
> following 4 years. I will keep this year's observation X_t iff I know
> for sure X_t+k is not missing for k=1,2,3,4 (i.e. I have data on X for
> every year in the next four years). This will go on for every year t
> from t=1 to T. I would be most grateful if you could please tell me
> the easiest way to do this kind of operation. Thanks very much in
>
> Best regards,
> Mic
> *
> *   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/
```