Hope someone can help me with this.
I have a dataset of households in various zip codes. I want to keep only
those hholds that are in 700 particular zip codes that I've identified.
The logical way to do this in stata is to write a command that looks like
this:
keep if zip=="12345" | zip=="12456" | zip=="00234" | zip==..............
There would be about 700 "or" conditions.
The problem is, Stata doesn't allow this many "OR" conditions in that
statement. This command works fine if I only put in 10 or 20 zips. It
gives me an error saying "too many literals" if I put in all 700 zips in
my list.
Is there any other way for me to perform this operation?
Yes. Hardcoding the desired zip codes in a program is a Very Bad Idwa. The
Stataish way to do this is by placing the desired codes in a dataset, and
then using merge. That way it is very easy to alter the list of desired
groups (in your case zip code areas). There is a FAQ on just this subject at