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

st: using the "or" in 'keep if' command

From   "Nisha Malhotra" <>
To   <>
Subject   st: using the "or" in 'keep if' command
Date   Fri, 14 Jun 2002 22:08:02 -0400

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?

This is doable in SAS, since there's a command:

if in (insert list of zip codes here);  

Perhaps there's an analogous command in Stata?

Thanks in advance for your help.

*   For searches and help try:

© Copyright 1996–2017 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index