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

st: RE: Formatting Columns in Tabstat

From   "DTI, Inc." <>
To   <>
Subject   st: RE: Formatting Columns in Tabstat
Date   Fri, 14 Jun 2002 19:40:39 -0700

You probably can do what you want by using -real- to generate the numeric
variable -newzip- from -zip-, reformat as integer, and then use the -egen-
-eqany newzip, values(12345, 12456, 234,...), to create a 0-1 variable to be
used with -keep-.


-----Original Message-----
[]On Behalf Of Nisha Malhotra
Sent: Friday, June 14, 2002 7:05 PM
Subject: st: Formatting Columns in Tabstat


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

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:

*   For searches and help try:

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