Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: Count non-missing


From   "Nikolaos Kanellopoulos" <[email protected]>
To   <[email protected]>
Subject   st: Count non-missing
Date   Sat, 28 Apr 2007 15:36:16 +0100

Dear all,

I am trying to create a variable that counts the number of nonmissing values
for another variable, but starts counting from the beginning when a missing
value is found.

In the folowing example I have an individual identifier (i) and a time
variable (t). I want to create var4 which counts the number of non missing
observations of x by I and t, but I want it to start counting when a missing
value appears on x.


+------------------+
i   t   x   var4 
------------------
1   1   1      1 
1   2   0      2 
1   3   1      3 
1   4   .      . 
1   5   1      1 
------------------
2   1   1      1 
2   2   1      2 
2   3   .      . 
2   4   0      1 
2   5   0      2 
+------------------+

Thanks in advance
Nikos

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index