Statalist


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

st: let loop stop when the first variable x becomes 0


From   Man Jia <[email protected]>
To   [email protected]
Subject   st: let loop stop when the first variable x becomes 0
Date   Thu, 19 Jun 2008 20:05:07 -0400 (EDT)

Dear Statalists,

I have a data set like this: 
-------------------------------------------------------------------
ID,x1995, x1996, x1997, x1998, x1999, x2000, x2001, x2002

 1   1         0          1          1       0          1          0    
  0
 2   0         0          0          0       1          0         0     
  0
 3   1         1          0          1       0          0         0     
  0
---------------------------------------------------------------------
I want to find out for each observation the first year when the value 
of the variable x becomes 0. 

For example, for observation 1, the first year x becomes 0 is 1996. For 
observation 2 and 3, 1995 and 1997 respectively.

I'm not sure how to let the "searching the first 0" loop stop when x 
becomes 0. I checked STATA's help; I was wondering if the command 
"continue" will work here. Could someone give me some hints about this? 

Thanks a lot!

Mandy Jia 


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