Announcement

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

  • putexcel - How to write out observations of a variable

    Apologies for a probably a very simple question, but I have tried reading docs and examples and can not see how to do this.

    I want to use -putexcel- to write out the observations of some variable.

    I have set up my file with this
    Code:
    putexcel set myresults, sheet("out1")
    sysuse auto
    And have tried the following 3 attempts to write out the observations of the variable "Price"


    Code:
    putexcel A2 = price
    Code:
    putexcel A2 = list price

    Code:
    mkmat price, matrix(matprice)
    putexcel A2 =  matrix(matprice)

    But none of these work. I get the error message
    Code:
    file myresults.xlsx could not be saved
    r(603);
    Any help appreciated, thanks for reading.

    * http://www.stata.com/manuals14/pputexcel.pdf

  • #2
    Well the embarrassing answer is my Excel file was left open, which is why it couldn't be saved.


    These two methods both work. Guess I'll leave this up if it helps anyone else in the future.

    Code:
     putexcel A2 = price
    Code:
     mkmat price, matrix(matprice)
    putexcel A2 =  matrix(matprice)
    Last edited by Sean Fiedler; 28 Mar 2016, 10:24.

    Comment


    • #3
      Yes, I think we have all been bitten by this at one time or another. It wold be helpful if -putexcel- and -export excel- gave a more specific message to the effect that the file can't be saved because it is open. When you are just working on your own computer, presumably you will sooner or later recognize this on your own. But if you are working on a network with shared files, you can be unaware that somebody else has that file open.

      Comment


      • #4
        Dear Clyde and Sean - or anyone else who maybe able to help - this is a related issue using putexcel in Stata14.

        using this : putexcel b2 = matrix(b), names - I am getting the following error message: "matrix columns out of Excel file range" r(198);

        Anyone know what I am doing wrong? - details below:

        Many thanks! Anne


        return list

        scalars:
        r(level) = 95

        macros:
        r(mcmethod) : "noadjust"

        matrices:
        r(table) : 9 x 400

        .

        . putexcel set eukidgirl.xls, replace


        . matrix b = r(table)

        . putexcel b2 = matrix(b), names
        matrix columns out of Excel file range
        r(198);

        Comment


        • #5
          The manual entry for putexcel links to the import excel manual entry for excel limits. The column limit may be biting:

          Technical note:
          Excel data size limits For an Excel .xls-type workbook, the worksheet size limits are 65,536 rows by 256 columns. The string size limit is 255 characters.

          For an Excel .xlsx-type workbook, the worksheet size limits are 1,048,576 rows by 16,384 columns. The string size limit is 32,767 characters.
          Stata/MP 14.1 (64-bit x86-64)
          Revision 19 May 2016
          Win 8.1

          Comment


          • #6
            Thank you Carole J. Wilson - that was the issue! thanks for a quick and helpful reply...

            Comment

            Working...
            X