|
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
Re: st: choosing based on number of observations
From
"Sebastian F. B�chte" <[email protected]>
To
[email protected]
Subject
Re: st: choosing based on number of observations
Date
Mon, 16 Apr 2007 17:22:24 +0200
I guess you would like to keep those counties for which at least five
or more observations exist in your dataset. If that is the case this
task can be easily solved with
bysort county: keep if _N>= 5
-bysort- and -by- (which is the same as bysort but it requires a
sorted dataset) are _extremely_ useful commands. You should check out
the corresponding helpfiles and learn more about the versatility of
these commands.
regs
sebastian
On 4/16/07, Alan Neustadtl <[email protected]> wrote:
Do you mean something like:
. keep if county > 5
or
. keep if county > 5 & county <.
Best,
Alan
On 4/16/07, Michael McCulloch <[email protected]> wrote:
> Dear Statalist members,
> I would like to choose records in which the number of observations in
> a field, here named county, is greater than 5. Below is a tabulation
> of county. I've examined the help file for -count-, but this doesn't
> seem to suit my needs. Any guidance would be appreciated. Thank you.
>
> . tab county
>
> COUNTY OF |
> RESIDENCE @ |
> DX | Freq. Percent Cum.
> ------------+-----------------------------------
> 0 | 34 0.61 0.61
> 1 | 1,055 18.78 19.39
> 3 | 23 0.41 19.80
> 4 | 11 0.20 19.99
> 5 | 8 0.14 20.14
> 6 | 3 0.05 20.19
> 7 | 656 11.68 31.87
> 9 | 53 0.94 32.81
> 10 | 6 0.11 32.92
> 12 | 4 0.07 32.99
> 15 | 1 0.02 33.01
> 17 | 38 0.68 33.68
> 18 | 1 0.02 33.70
> 19 | 2 0.04 33.74
> 20 | 2 0.04 33.77
> 21 | 174 3.10 36.87
> 22 | 1 0.02 36.89
> 23 | 10 0.18 37.07
> 27 | 6 0.11 37.17
> 28 | 104 1.85 39.02
> 29 | 27 0.48 39.51
> 31 | 102 1.82 41.32
> 32 | 1 0.02 41.34
> 33 | 2 0.04 41.37
> 34 | 855 15.22 56.60
> 35 | 6 0.11 56.70
> 36 | 1 0.02 56.72
> 37 | 2 0.04 56.76
> 38 | 445 7.92 64.68
> 39 | 85 1.51 66.19
> 40 | 2 0.04 66.23
> 41 | 430 7.66 73.88
> 43 | 699 12.44 86.33
> 44 | 27 0.48 86.81
> 45 | 5 0.09 86.90
> 48 | 362 6.44 93.34
> 49 | 255 4.54 97.88
> 50 | 22 0.39 98.27
> 51 | 7 0.12 98.40
> 52 | 2 0.04 98.43
> 53 | 1 0.02 98.45
> 54 | 3 0.05 98.50
> 55 | 13 0.23 98.74
> 57 | 54 0.96 99.70
> 58 | 12 0.21 99.91
> 230 | 1 0.02 99.93
> 641 | 1 0.02 99.95
> 999 | 3 0.05 100.00
> ------------+-----------------------------------
> Total | 5,617 100.00
> *
> * 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/
*
* 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 |