Notice: On March 31, it was **announced** that Statalist is moving from an email list to a **forum**. The old list will shut down on April 23, and its replacement, **statalist.org** is already up and running.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

From |
massimiliano stacchini <mastacchini@yahoo.it> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
st: capturing the sizes of the sequences of countinous (uninterrupted) values equal to 1 |

Date |
Wed, 30 Nov 2011 09:24:31 +0000 (GMT) |

Dear users, I have a huge dataset. The rows identify the person ID (i) (i=1,...,n) while in columns there are the reference dates TIME(t) (t=1,...,w). Each cells contain the value 1 or 0 (zero), alternatively. I should create a variable (LENGTH) varying both over ID and TIME. For each i of ID(i) in t of TIME(t), LENGTH should captures the number of continuous (uninterrupted) values which are equal to 1 in the interval of cells starting from the reference data t of TIME and moving backwards to the previous reference dates. In other terms , LENGTH should capture for each (i) of ID and for each (t) of TIME the number of s in T (t-s) identifying cells having values equal to 1 (i.e., the size of the sequence of uninterrupted 1 moving backwards to the previous reference dates). Can you help me on how can I get this result with Stata? Thanks * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/

**Follow-Ups**:**Re: st: capturing the sizes of the sequences of countinous (uninterrupted) values equal to 1***From:*Nick Cox <njcoxstata@gmail.com>

- Prev by Date:
**Re: st: Working with complex strings** - Next by Date:
**Re: st: rclass AND sclass AND eclass** - Previous by thread:
**st: xtfrontier and frontier** - Next by thread:
**Re: st: capturing the sizes of the sequences of countinous (uninterrupted) values equal to 1** - Index(es):