Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: recast float to integer produces change, but round(var)-var=0


From   Nick Cox <[email protected]>
To   [email protected]
Subject   Re: st: recast float to integer produces change, but round(var)-var=0
Date   Tue, 22 Jan 2013 04:13:16 +0000

The limits of an -int- are much more restricted than those of a -float-.

See -help data types-.

So, very likely all values of your -float- variable outside those
limits have been -force-d to missings.

You asked for -force- to be applied and Stata obliged, but just
possibly it was not a good idea.

For example, try this (given that -float- is the default default
numeric type (doubling intentional))

clear
set obs 10
gen foo = 42000
recast foo, force
list

Everything is now missing.

Whenever -force- is the name of an option, it does mean what it says.
Violence to data is a likely consequence, but the presumption is if
you choose -force-, then you know what you are doing.

Nick

On Tue, Jan 22, 2013 at 12:05 AM,  Maxime Roy <[email protected]> wrote:

> I hope someone can help me with this possibly basic question.
>
> I have a "var" stored as a float.
>
> let
>
> "gen diff = round(var) - var".
>
> I also have:
>
> "count if diff!=0" returns: 0.
>
> However,
>
> "recast int var, force" leads to "X values changed" (where X>0).
>
> I am puzzled, I would have expected "0 values changed". Can someone
> provide an explanation.
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index