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
>>> [email protected] 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: [email protected]
[mailto:[email protected]]On Behalf Of Nisha Malhotra
Sent: Friday, June 14, 2002 7:05 PM
To: [email protected]
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/