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 |
Nick Cox <n.j.cox@durham.ac.uk> |

To |
"'statalist@hsphsun2.harvard.edu'" <statalist@hsphsun2.harvard.edu> |

Subject |
RE: st: Data management |

Date |
Thu, 21 Oct 2010 11:52:19 +0100 |

Chris's approach is good, with the addition that the SD can be missing as well as zero; such observations are presumably of no interest either. He is also correct that there are other ways to do it, which follow from the principles explained in FAQ . . . . . . Listing observations in a group that differ on a variable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . N. J. Cox 11/01 How do I list observations in a group that differ on a variable? http://www.stata.com/support/faqs/data/diff.html So, for example, consider bysort hhn (rentaltype) : keep if rentaltype[1] != rentaltype[_N] Nick n.j.cox@durham.ac.uk Chris Parker One option (I'm sure more concise options will follow) is: bysort hhn: egen hasboth=sd(rentaltype) drop if hasboth==0 This removes any observations where there is no variation in the rental type across the household. Jeetendra Aryal > I have a big data set which is as follows: > HHN PN Rental type > 1 1 1 > 1 2 0 > 1 3 0 > 2 1 1 > 2 2 1 > 3 1 1 > 3 2 0 > 3 3 1 > 4 1 1 > 4 2 1 > 4 3 1 > 5 1 0 > 5 2 1 > 5 3 1 > > Now the question is: Each household has more than one plot of land. The household can use it or rent it out or both. I want to keep only those households which have both rental types. For example, in the above dataset I want to keep only household number 1, 3 and 5. Is there any way that I can do it easily, rather than doing manually? * * 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/

**References**:**st: Data management***From:*Jeetendra Aryal <jeetendra.aryal@umb.no>

**Re: st: Data management***From:*Chris Parker <cparker.phd2007@london.edu>

- Prev by Date:
**st: RE: Removing (partial) duplicate obs with lots of vars** - Next by Date:
**st: RE: Delta of two time variables (%tc) in minutes** - Previous by thread:
**RE: st: Data management** - Next by thread:
**st: FW: stcrreg: when the proportional hazards assumption fails** - Index(es):