Announcement

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

  • Export Correlation Matrix to Excel: Putexcel No Longer Working

    Hi Statalisters,
    I know this sounds quite trivial. I am surprised as well.
    I currently use Stata16 and I have been using the "putexcel" command since 2013 with Stata13.
    I suddenly realise that my "save-time" putexcel export command is no longer responding.

    Here's the code:
    corr var_x1 var_x2 var_x3
    return list
    matrix list r(C)
    putexcel A1=matrix(r(C), names) using C:\Users\ng\Desktop\ICT.xlsx, modify


    This is the same code I've always used but suddenly returns the below-mentioned error which was never the case:
    using not allowed
    r(101);


    I tried with Stata13 and Stata15 and got the same error.
    Kindly assist in this regard.
    Thanks.
    Ngozi

  • #2
    My guess is that you have confused the syntax of the export excel command, which includes the using qualifier, with that of the putexcel command, which does not include the using qualifier. For putexcel, something like the following is needed.
    Code:
    putexcel set C:\Users\ng\Desktop\ICT.xlsx, modify
    putexcel A1=matrix(r(C), names) 
    ...
    putexcel save

    Comment


    • #3
      Thanks, William for your response but I still got an error with the code. Here's what I did:

      putexcel set C:\Users\ng\Desktop\ICT.xlsx, modify
      putexcel A1=matrix(r(C), names)
      corr gfcf labour cpi
      return list
      matrix list r(C)
      putexcel save


      names not found
      r(111);


      I also substituted the variable names with "names" hoping that will work, but still got an error.

      It is still strange that the previous syntax work isn't working anymore because I have been using that putexcel command since 2013.

      I'll appreciate further help on this, thanks!

      Ngozi

      Comment


      • #4
        Hi William,
        I modified the code by removing "names". That is:

        putexcel set C:\Users\ng\Desktop\ICT.xlsx, modify
        putexcel A1=matrix(r(C))
        corr gfcf labour cpi
        return list
        matrix list r(C)
        putexcel save


        It gave no error. The output is exported to excel but without the names of the variables. Is there a way to correct this?
        Thanks.
        Last edited by Ngozi ADELEYE; 12 Nov 2019, 23:08. Reason: I made some adjustments.

        Comment


        • #5
          Perhaps it has been a while since you used putexcel, and it is time to review the output of help putexcel to refresh your memory with the command.
          Code:
          sysuse auto, clear
          putexcel set gnxl.xlsx, modify
          corr length weight price
          return list
          matrix list r(C)
          putexcel A1=matrix(r(C)), names
          putexcel save
          Click image for larger version

Name:	gnxl.png
Views:	1
Size:	226.7 KB
ID:	1524497

          Comment


          • #6
            Thanks, William, it works!!!
            You're the best!...and yes, I need to refresh my memory.
            ...gracias!
            Ngozi

            Comment

            Working...
            X