Statalist


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

st: R: identifying a string of consecutive numbers


From   "Carlo Lazzaro" <carlo.lazzaro@tin.it>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: R: identifying a string of consecutive numbers
Date   Wed, 16 Apr 2008 15:22:25 +0200

Dear Jon,

please take a look at what follows:
--------------------------------------------------------------------
g Indicator=1  if  year_1==1 &  year_2==1 &  year_3==1 &  year_4==1 |
year_4==0 &  year_5==0

replace Indicator=2 if Indicator==.
---------------------------------------------------------------------

HTH and Kind Regards,

Carlo


-----Jon wrote:-----

Dear List,

I'm hoping someone can help me with this b/c I'm
totally stumped. I have a wide data set and am trying
to identify observations that have a series of
consecutive zeros following any positive number. 

For example, say I have 5 years of data and the
following information for 5 observations:

ObsA  1 1 1 1 0
ObsB  1 1 1 0 0
ObsC  1 1 0 0 1
ObsD  1 0 1 1 1 
ObsE  0 0 0 0 1 

The variable names are something like yr1, yr2, yr3,
yr4, yr5. I would like to create a variable that
differentiates ObsA and ObsB from the other three.

Any and all thoughts are appreciated.

Thanks,
jon
 


 
____________________________________________________________________________
________
Be a better friend, newshound, and 
know-it-all with Yahoo! Mobile.  Try it now.
http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ

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


*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index