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: limit to number of digits that can be precisely input into a Stata dataset using -insheet-?
From
Nick Cox <[email protected]>
To
[email protected]
Subject
Re: st: limit to number of digits that can be precisely input into a Stata dataset using -insheet-?
Date
Mon, 14 May 2012 22:15:34 +0100
Read in long numeric identifiers as string.
More generally, start with
http://blog.stata.com/2012/04/02/the-penultimate-guide-to-precision/
Nick
On Mon, May 14, 2012 at 9:50 PM, Beede, David N <[email protected]> wrote:
> Is 15 the maximum number of digits one can safely (i.e., precisely) input into a Stata dataset using -insheet-?
>
> I've seen in the statalist archives someone saying that "about 16" is the limit (which I assume is related to the precision for double being 1.414 e-16 (according to the "data types" article in the documentation).
>
> I'm a little bit nervous because I have been reading in csv file using -insheet- with Census Block identification numbers which are 15 digits long without any apparent problems, but when I used -insheet- to read in an id number that was 19 digits long the resulting Stata dataset did not retain the full 19 digits of precision.
>
> I know this is not a very scientific demonstration, but...
>
>
> . type test.csv
> 500019601001002,5000196010010022,50001960100100222,500019601001002222,5000196010010022222
>
> . insheet using test.csv, clear comma nonames
> (5 vars, 1 obs)
>
> .
> . forvalues x=1(1)5 {
> 2. local y=`x'+14
> 3. gen str`y' s`x' = string(v`x', "%0`y'.0f")
> 4. }
>
> . l s*
>
> +-----------------------------------------------------------------------------+
> 1. | s1 | s2 | s3 | s4 |
> | 500019601001002 | 5000196010010022 | 50001960100100224 | 500019601001002240 |
> |-----------------------------------------------------------------------------|
> | s5 |
> | 5000196010010021900 |
> +-----------------------------------------------------------------------------+
>
*
* 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/