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

From |
Doug Owens <dho@tamu.edu> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: identify group of observations |

Date |
Wed, 28 Apr 2004 21:47:13 -0500 |

At 08:54 PM 4/28/2004 -0500, you wrote:

At 06:08 PM 4/28/2004 -0400, MITRA PINAKI (MAR1PXM) wrote:Hello List, I have a data set where I need to group observations. The identifying flag is two character string which can be either "01" or "02". Each "01" observation is followed by "02", so the flag for the first obs is "01" and the very next one's is "02". But these are always not in pair; order can be "01" and "02"; "01", "02", "02"; "01", "02", "02, "02" and so on. All the "02" obs. followed by "01" belong to one group. Is there any way I can generate an identifier that indicates these groups?

Do you have that backwards? i.e. All the "01" obs. followed by "02" belong to one group. That would have been my guess based on your examples.

Assuming you want to create grp like: Flag grp 01 1 02 1 01 2 02 2 02 2 01 3 02 3 02 3 02 3 Then you can just gen grp = flag=="01" replace grp = sum(grp)

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

**Follow-Ups**:**Re: st: identify group of observations***From:*Richard Williams <Richard.A.Williams.5@nd.edu>

**References**:**Re: st: identify group of observations***From:*Richard Williams <Richard.A.Williams.5@nd.edu>

- Prev by Date:
**Re: st: identify group of observations** - Next by Date:
**Re: st: identify group of observations** - Previous by thread:
**Re: st: identify group of observations** - Next by thread:
**Re: st: identify group of observations** - Index(es):

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