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." <frank@data2information.com>
To   <statalist@hsphsun2.harvard.edu>
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-
function,
-eqany newzip, values(12345, 12456, 234,...), to create a 0-1 variable to be
used with -keep-.

..Frank

-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu]On Behalf Of Nisha Malhotra
Sent: Friday, June 14, 2002 7:05 PM
To: statalist@hsphsun2.harvard.edu
Subject: st: Formatting Columns in Tabstat

Hi,

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:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/

*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index