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

st: RE: many zip codes to select (about 700)


From   "Jens M. Lauritsen" <[email protected]>
To   [email protected]
Subject   st: RE: many zip codes to select (about 700)
Date   Sun, 16 Jun 2002 22:04:46 +0200

The obvious way to this in my view would be:
1. Have your actual dataset in one file, say Mydata.dta
2. Create a second dataset with the desired zip codes, say ZipCodes.dta If you have those 700 in a txt file it is easy:

*read from the ascii-txt file with the 700 numbers:
insheet zip using mylist.txt
sort zip
save ZipCodes.dta

* read your actual dataset
use Mydata.dta
sort zip

* merge with the zipcodes dataset based on the zip
merge zip using ZipCodes.dta

/*now a new variable _merge is made which has three values:
1: Only in Mydata.dta
2: Only in ZipCodes
3: In both
*/
tab _merge

* then as a test find zipcodes you thought were there:
tab zip if _merge == 2

* And keep only the relevant ones.
Then find the
drop if _merge == 2

Kind Regards
Jens M.Lauritsen
Jens M. Lauritsen, Consultant,MD. PhD.
Accident Analysis Group, Odense University Hospital,
Odense, Denmark
e-mail: [email protected]
Initiator of EpiData, see www.epidata.dk for DataEntry in windows (EpiInfo V6 principle)
For E-Mail news on EpiData, sign on at www.epidata.dk/maillist.php
*
* 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