Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • CSV file creation without exponential numbers

    Hi everybody,

    I'm using Stata 13 and need to save my dataset (with quite large and very small numbers) as CSV.
    However I need numbers in the CSV to be stored without exponential notation (and I don't wish to standardize them).

    Any way to do that with the stata export?
    I tried using Excel and went crazy.

    Thanks a lot!
    Andrea.
    Last edited by Andrea Arancio; 28 Sep 2015, 11:54.

  • #2
    You can convert the numbers to strings before export from Stata 13.
    Code:
    sysuse auto, clear
    replace price = price * 1000000000
    replace mpg = mpg / 1000000000
    tostring price, replace format(%14.0f)
    tostring mpg, replace format(%14.12f) force
    export delimited price mpg using "test1.csv", replace
    With Stata 14 this isn't necessary because Stata 14 has a datafmt option for export delimited.
    Code:
    sysuse auto, clear
    replace price = price * 1000000000
    replace mpg = mpg / 1000000000
    format price %14.0f
    format mpg %14.12f
    export delimited price mpg using "test2.csv", datafmt replace

    Comment


    • #3
      Thanks Friedrich!
      Last edited by Andrea Arancio; 28 Sep 2015, 14:24.

      Comment


      • #4
        You didn't provide an excerpt from your data so I used the auto data that is installed with Stata in the examples above. I multiplied price by 1,000,000,000 and divided mpg by 1,000,000,000 to create variables with large and small numbers.

        Comment

        Working...
        X