Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: possible bug in outsheet?


From   Adrian Mander <[email protected]>
To   [email protected]
Subject   Re: st: possible bug in outsheet?
Date   Mon, 16 Apr 2007 15:29:51 +0100

Thanks Joseph I never noticed that it was the display format that was driving outsheet.

So let's get back to the original question and actually this feature isn't documented anywhere that I could find.
Interestingly the manual states about outsheet "About all that can go wrong is that the file you specify already exists:".

I received this dataset from someone else and I doubt that I would ever change display formats.

For exporting data wouldn't it be better to use the most accurate dataset (obviously to how ever many digits that Stata is accurate to, I
vaguely remember something about 24 bit numbers)? Or perhaps Stata could be slightly more intelligent and figure out the best
display format or at least within some accuracy realise that the display format is insufficient for the current variable and give a warning message?

cheers
Ade




At 14:53 16/04/2007, you wrote:

One more time, to supplement the first reply:  it seemed have been on
the -outsheet- side rather than on the -insheet- side.  -outsheet- formats
the output according to the display format, which was %2.0f in your example.
This is where the truncation (rounding) appears to have occurred.  In the
example below, Stata isn't tricked even by 199 integer zeroes on
the -insheet- step.

Joseph Coveney

. clear

. set seed `=date("2007-04-16", "ymd")'

. set obs 1
obs was 0, now 1

. tempfile tmpfil0

. generate double a = uniform()

. tostring a, replace format(%18.16f)
a was double now str18

. set obs 200
obs was 1, now 200

. replace a = "0" in 2/200
(199 real changes made)

. generate byte last = _n == 1

. sort last

. replace last = 1 in 1
(1 real change made)

. outsheet using `tmpfil0', noquote

. insheet using `tmpfil0', double clear
(2 vars, 200 obs)

. describe

Contains data
 obs:           200
vars:             2
size:         2,600 (99.9% of memory free)
-------------------------------------------------------------------------------
             storage  display     value
variable name   type   format      label      variable label
-------------------------------------------------------------------------------
a               double %10.0g
last            byte   %8.0g
-------------------------------------------------------------------------------
Sorted by:
    Note:  dataset has changed since last saved

. format a %18.16f

. list a if last

    +--------------------+
    |                  a |
    |--------------------|
 1. | 0.0000000000000000 |
200. | 0.6328111810144037 |
    +--------------------+

. erase `tmpfil0'

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