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

Re: st: latest update of cut


From   [email protected] (Jean Marie Linhart, StataCorp.)
To   [email protected]
Subject   Re: st: latest update of cut
Date   Wed, 07 Aug 2002 12:04:48 -0500

Michael Hills <[email protected]> wrote:
> I was disturrbed to find that in the latest ado update the cut
> function of egen has changed how it deals with missing values.
>
> In the version before the update, when you cut a variable with missing
> values, these were coded as missing in the new variable. Now they are
> coded with the upper limit specified in cut.
>
> I can see no logic in this and I presume it is an error which has been
> introduced during the latest update of cut. There is no change in the
> help file for egen.

The change to -egen, cut- was intentional; it was pointed out by a
user that its behavior did not match the documentation.  I concurred
and modified the function to better match the documentation.

Previously when -egen, cut- was used with the -at- option, the
(ascending) list of numbers are intended left hand endpoints for
subdividing the data.  However any member of the input data greater
than or equal to the largest value in -at- got mapped to missing.  
This contradicted the notion that the list of numbers was intended
as left hand endpoints.

I modified -egen, cut- so that the values of the input data that are
greater than or equal to the largest value in -at- are mapped to the
largest value in the -at- list.

Since missing values are greater than numerical values, this resulted
in the behavior that now missing values are mapped to the largest
value specified in -at-.  This makes sense to me given that the values
in -at- are intended as left hand endpoints.

If the user wishes to exclude missing values, it is easy to accomplish
this using the -if- or -in- options.  For example,

. egen newx = cut(x), at(2, 4, 6) if x != .

The documentation for -egen, cut- says nothing about what happens
to missing values, but perhaps it should.  I'll get that done.

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

--Jean Marie
[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