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

st: RE: data cleaning


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: data cleaning
Date   Wed, 19 Jun 2002 10:54:56 +0100

Babigumira  Ronnie

> I am trying to clean some data here. The variable "credsrc" (credit
> source) lies within 3 ranges 111-114 (for formal sources) or 211-236
> (Microfinance) or 311-321 (informal sources). Can't seem to figure out the
> logical syntax that will smoke out the illegal entries (such as >114 but
> <211, >236 but <311, >321). Someone please help me
>
> Variable would look something like this
> Credsrc
> 114
> 112
> 315
> 214
> 220
> 318

I'll assume these are numeric not string codes. If not, -destring-.

Two possibilities:

egen OK = eqany(credsrc), values(111/114 211/236 311/321)

gen OK = inrange(credsrc,111,114) | inrange(credsrc,211,236) |
inrange(credsrc,311,321)

list credsrc if !OK

Nick
[email protected]

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