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

st: thanks


From   "Ahmed Mushfiq Mobarak" <Mobarak@econ.bsos.umd.edu>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: thanks
Date   Sat, 15 Jun 2002 18:04:49 -0400

Thank you Nisha, for forwarding this. I actually only meant it as a question for you - but it's nice of you to forward it to statalist.

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.  

I've come to the conclusion that it's worth learning *both* SAS and stata, especially if you work with large datasets.

Mushfiq

>>> frank@data2information.com 06/14/02 10:40PM >>>
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/

*
*   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