Statalist


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

Re: st: How to label the value 999999999999


From   Nick Winter <nwinter@virginia.edu>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: How to label the value 999999999999
Date   Wed, 08 Oct 2008 11:39:56 -0400

Trial and error suggests that -label- will handle integers from -2,147,483,647 through 2,147,483,621, plus the extended missings from .a through .z, and NOT 'regular' missing (.):

. la de mylab 2147483621 "really big"

. la de mylab 2147483622 "really big + 1", add
may not label 2147483622
r(198);

. la de mylab -2147483647 "really negative", add

. la de mylab -2147483648 "really negative - 1", add
may not label -2147483648
r(198);

. la de mylab . "missing", add
may not label .
r(198);

. la de mylab .a "missing a", add

. la de mylab .z "missing z", add


Oddly, the upper bound is one larger than the maximum for a -long- in Stata (according to -help data types-); the lower bound is the mimimum for a -long-.

Nick Winter



Caleb Southworth wrote:
Nick, thanks for this. The main issue is still unclear: is there a limit on the size of number that can be labeled? My suggestion of mvencode and the other similar recodes are the way to go.
On Wed, 8 Oct 2008, Nick Cox wrote:

:No; this is backward. It's the argument that is problematic, not the
:result. :
:The possible length of the value label, i.e. a string, is not biting
:here. It is the fact that you are dealing with a large integer, on which
:more is said elsewhere. :
:The refusal of -tostring- to produce a string variable in your example
:is easy to explain. -tostring- is a wrapper for -string(<real argument>,
:"<format>")- with several safety checks and constraints. The format
:defaults to %12.0g. Some experiments show that you need a different
:format for the conversion of 9...9 (12 digits) to be reversible. :
:. di string(999999999999, "%12.0g")
:1.00000e+12
:
:. di string(999999999999, "%13.0g")
:1.000000e+12
:
:. di string(999999999999, "%14.0g")
:999999999999
:
:So, -tostring- will work as desired here so long as a suitable
:-format()- is specified. *
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/

--
--------------------------------------------------------------
Nicholas Winter                                 434.924.6994 t
Assistant Professor                             434.924.3359 f
Department of Politics                  nwinter@virginia.edu e
University of Virginia          faculty.virginia.edu/nwinter w
PO Box 400787, 100 Cabell Hall
Charlottesville, VA 22904

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index