Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: Re: How to list just the first case meeting a selection criterion?


From   "Michael Blasnik" <[email protected]>
To   <[email protected]>
Subject   st: Re: How to list just the first case meeting a selection criterion?
Date   Mon, 27 Jun 2005 19:37:02 -0400

Given the large dataset, I would just drop all of the cases after the first for each criteria grouping, the you can list whatever you like quickly and easily:

bysort county precinct: keep if _n==1

Then you could:

list if county==xxx & precinct==y

It will be much faster working with the reduced dataset. Just remember not to save,replace.

Michael Blasnik
[email protected]

----- Original Message ----- From: "paul gronke" <[email protected]>
To: <[email protected]>
Sent: Monday, June 27, 2005 7:09 PM
Subject: st: How to list just the first case meeting a selection criterion?



I am dealing with an extremely large (2 gig) dataset and wish to list
just the first case that meets a set of criteria.  There are about 200
separate sets of criteria (county and precinct values).

Thus, I'd like a command that does something like:

list name address1 address2 county precinct city state
    if [first one of] county=VALUE & precinct=VALUE

repeated about 200 times.

I could do this with
    sample 1 if CRITERIA

but that seems needless complex, especially since all I want is the
first case that meets 200 combinations of county and precinct.

Thanks
Paul Gronke
Reed College
*
*   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