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

Re: st: Puzzled by behavior of -recode varlist (.a/.z=.)-


From   Richard Williams <[email protected]>
To   [email protected]
Subject   Re: st: Puzzled by behavior of -recode varlist (.a/.z=.)-
Date   Fri, 23 Apr 2004 13:22:32 -0500

At 12:53 PM 4/23/2004 -0400, Renzo Comolli wrote:
Dear Statalist,

By reading the manual, I see that there is an instruction
. recode varlist (missing=.)
that does exactly what I meant to do, so I am all set as far as my work is
concerned. I am just curious to understand.
The bahavior of
. recode varlist (.a/.z=.)
resembles
. recode varlist (nonmissing=.)
And it looks inconsistent with the rest of the -recode- syntax to me.

Am I just totally confused? Or is there something wrong here?
Definitely sounds like odd behavior to me. Looking at -recode.ado-, I notice there are these lines:

else if length(`"`v'"')==2 & inrange(`"`v'"',".a",".z") {
return local s1 `v'

Now, I haven't waded through the whole ado file, but I wonder if that line is doing what it is supposed to do. According to the online docs for inrange,

"inrange(z,a,b) returns 1 if it is known that a <= z <= b; otherwise, this function returns 0. If z = missing (.) this function returns 0. For numeric arguments, if a = missing and/or b = missing these values are interpreted as a = -infinity and/or b = +infinity, respectively."

Now, I just tried the command

. gen z = inrange(var1, .a, .z)

where var1 was a mixture of missing and nonmissing values, and z = 0 for every case. This is consistent with the docs saying "If z = missing (.) this function returns 0" but it is not consistent with what the users intent would probably be in this case.

Anyway, it is hard for me to believe that this is not a bug, and my wild guess is that it might have something to do with the use of the inrange command as shown above. But, it could be something else.



-------------------------------------------
Richard Williams, Associate Professor
OFFICE: (574)631-6668, (574)631-6463
FAX: (574)288-4373
HOME: (574)289-5227
EMAIL: [email protected]
WWW (personal): http://www.nd.edu/~rwilliam
WWW (department): http://www.nd.edu/~soc


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