Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


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

Re: st: retaining numeric formatting when using -outsheet-


From   Neil Shephard <nshephard@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: retaining numeric formatting when using -outsheet-
Date   Thu, 23 Dec 2010 15:24:45 +0000

On Thu, Dec 23, 2010 at 3:16 PM, Beede, David N <dbeede@doc.gov> wrote:
> Hi -
>
> I know this topic has come up before, and the answer was to set the display format within Stata.  But even so, I am having problems with it.  I have done a lot of due diligence to try to find the answer but can't (I also tried using StatTransfer and -xmlsave- without success).  I want to avoid as much format-fussing in Excel as I can, but if I have to I guess I will. But if anyone has a quick fix, I would be grateful to know it.  Thanks.
>
> Here is a snippet of code:
>                recast double v*
>                format v* %20.0fc
>                format *
>                l v1 v2
>                outsheet v1 v2 using test.csv, replace comma
>
> Here is an excerpt from the Stata log corresponding to the snippet:
> variable name  display format
>  -----------------------------
>  v1             %20.0fc
>  v2             %20.0fc
>  -----------------------------
>
>     +----------------------+
>     | v1                v2 |
>     |----------------------|
>  1. | 21    27,649,503,232 |
>  2. |  0                 0 |
>  3. | 48   213,393,129,472 |
>  4. | 18   185,502,416,896 |
>     +----------------------+
> And here is what the Excel file looks like after using -outsheet-
> v1      v2
> 21      27649503232
> 0       0
> 48      2.13393E+11
> 18      1.85502E+11

This sounds more like an Excel issue.

To investigate open the CSV in a text-editor (NOT Excel or Word) and
look at the format of your strings.

My guess is that they will look as desired, which means its Excel that
is choosing to display "213,393,129,472" as "2.13393E+11" and so
forth.  I don't have a version of Excel with which to check this
(since I exclusively run Linux) but there are ways of formatting
columns in Excel (something like right-clicking the column and
selecting "Format cells" or similar) that should allow you to set the
display format as desired before then saving it as an Excel file (i.e.
with extensions .xls so that formatting will be retained).

Neil

-- 
"Our civilization would be pitifully immature without the intellectual
revolution led by Darwin" - Motoo Kimura, The Neutral Theory of
Molecular Evolution

Email - nshephard@gmail.com
Website - http://kimura-no-ip.org/
Photos - http://www.flickr.com/photos/slackline/

*
*   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   |   Site index