Announcement

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

  • Export to Excel in Percent format

    Hi Statalisters,

    I'd like to export some numbers to an Excel file, and automatically set the format of the cells in the Excel file as percentages. Any ideas for how to do this? I'd prefer to keep it as a number formatted as a percent (so it will be stored as 0.03 but displayed as 3%), if possible. Thanks!

  • #2
    Stata doesn't have a percent display format. You can export 3 or 0.03 or "3%" as a string but I think those are the only pertinent options. I can't speak for what's possible in Excel.

    Some previous discussions, which don't affect the above:

    http://www.stata.com/statalist/archi.../msg00357.html

    http://www.stata.com/statalist/archi.../msg00506.html
    Last edited by Nick Cox; 14 Jan 2016, 12:39.

    Comment


    • #3
      If you are using Stata 14, you can use -putexcel- to specify the numeric format of Excel cells, an example:

      Code:
      putexcel set text.xlsx
      putexcel A1 = 0.25, nformat(percent)
      The code is for Stata 14.1, so make sure your Stata 14 is fully updated. See -help putexcel- for details.

      Comment


      • #4
        are you talking about "export excel" or "putexcel" - putexcel is much more versatile and gives the user much more control - see the help file ("h putexcel")

        Comment


        • #5
          Putexcel's option nformat(percent) does not behave as documented on my computer. I tested it explicitly in different ways. Decimals are displayed in Excel as integers, e.g. 0,75 as 1 instead of an expected 75%.

          I'd love this to be fixed in a future version. Off topic: It would also be great, if putexcel would be able to set the height and width of rows and columns.

          I use Excel 2013 and Stata 14.2.

          eric_a_booth below: Well, I look forward to an update to Stata 15.1 now...
          Last edited by Alexander Burstedde; 04 Jan 2018, 06:10.

          Comment


          • #6
            Alexander Burstedde Works just fine for me (Stata 15.1 , Excel 2013).

            Code:
             putexcel set text.xlsx
            putexcel A1 = 0.75, nformat(percent)
            Perhaps you should show the code you are running to produce the error?
            Click image for larger version

Name:	Screen Shot 2018-01-04 at 6.58.20 AM.png
Views:	1
Size:	25.9 KB
ID:	1424400
            Eric A. Booth | Senior Director of Research | Far Harbor | Austin TX

            Comment

            Working...
            X