Statalist The Stata Listserver


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

Re: st: possible bug in outsheet?


From   Joseph Coveney <[email protected]>
To   Statalist <[email protected]>
Subject   Re: st: possible bug in outsheet?
Date   Mon, 16 Apr 2007 22:53:07 +0900

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/



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