Announcement

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

  • Stata 16 does not export decimal points to Excel

    I am facing this problem in Stata 16. When I export data to Excel using Stata 16, the decimal points are all rounded to zero, but this does not happen in Stata 14.

    Stata 14
    Code:
    . clear
    
    . set seed 1234
    
    . set obs 10
    
    . gen var = uniform()
    
    . list
    
         +----------+
         |      var |
         |----------|
      1. | .9472316 |
      2. | .0522234 |
      3. | .9743183 |
      4. | .9457484 |
      5. | .1856478 |
         |----------|
      6. | .9487334 |
      7. | .8825376 |
      8. | .9440776 |
      9. | .0894259 |
     10. | .7505445 |
         +----------+
    and the Excel output
    Click image for larger version

Name:	Capture.PNG
Views:	1
Size:	15.6 KB
ID:	1517178


    And now the same in Stata 16

    Code:
    . clear
    
    . set seed 1234
    
    set obs 10
    
    . gen var = uniform()
    
    . list
    
         +----------+
         |      var |
         |----------|
      1. | .9472316 |
      2. | .0522234 |
      3. | .9743183 |
      4. | .9457484 |
      5. | .1856478 |
         |----------|
      6. | .9487334 |
      7. | .8825376 |
      8. | .9440776 |
      9. | .0894259 |
     10. | .7505445 |
         +----------+
    export excel using "C:\temp\example2.xls", firstrow(variables)
    And the output looks like this in Excel.

    Click image for larger version

Name:	Capture.PNG
Views:	1
Size:	5.2 KB
ID:	1517179


    Thanks for your comments.

  • #2
    Are you sure this is not a display option (format) issue in excel?

    Comment


    • #3
      In Excel, I can increase decimal points but that is a hectic job, especially, I have 100 of variables where each variable has specific number of decimal points. When Stata 14 can export all decimal points correctly, why not Stata 16. I am using the same Excel software for opening the files created by Stata 14 and 16.

      Comment


      • #4
        You can insist that the cell format be preserved

        Code:
        export excel using ..., firstrow(variables) keepcellfmt

        Comment


        • #5
          The suggestion by Andrew Musau does the trick.

          Comment


          • #6
            Originally posted by Jorrit Gosens View Post
            Are you sure this is not a display option (format) issue in excel?
            I think this is an example of Excel "helping" wit formatting. Andrew Musau's suggestion will do what you seek.

            Comment


            • #7
              It seems that Stata add "keepcellfmt" option (when writing data, preserve the cell style and format of existing worksheet) to export excel since version 15. In Stata 14, there's no keepcellfmt option at all.

              Comment

              Working...
              X