[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
st: Re: keep based on zip codes
On Sunday, June 16, 2002, at 02:33 AM, Ahmed wrote:
I ended up doing it in SAS, but Diana later gave me a stata suggestion
which also works. It's the "for" command in Stata that does the same
thing Frank suggests below.
The much better way to do this is to place the (sorted) zip codes (using
the same variable type that appears in your existing file) in a separate
Stata .dta file, say wantzip.dta; then all you have to do is
I've come to the conclusion that it's worth learning *both* SAS and
stata, especially if you work with large datasets.
You probably can do what you want by using -real- to generate the
email@example.com 06/14/02 10:40PM >>>
variable -newzip- from -zip-, reformat as integer, and then use the
- -eqany newzip, values(12345, 12456, 234,...), to create a 0-1
variable to be
used with -keep-.
merge zip using wantzip
keep if _merge==3
which will keep the records in the big file that have the zipcodes in
the wantzip file. No need to have a command with 700 values in it!
* For searches and help try: