Announcement

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

  • Error message with 'collect export' in Stata 17

    Hello,

    I have a large descriptive Table 1 that I'd like to try to export to an Excel file for a manuscript, where I describe people based on their vaccination history. I am using Stata/BE 17.0. I am relatively inexperienced with 'collect' and 'collect export' (and 'table', and 'putexcel', and a lot of other things), but I got the following code to work several times and then it started bombing! I am not sure what could have happened, but perhaps it's obvious to someone else.

    Here is my code:
    Code:
    foreach item in var1 var2 var3 var4 var5 {
    table (`item') (vax_history), statistic(frequency) statistic(percent, across(`item')) nototals
    collect layout (`item') (vax_history#result) (), name(Table)
    collect export "C:\Users\me\exceldocument.xlsx", sheet(`item') modify
    }
    This worked the first few times I ran it, and the excel documents were produced. Then, about the 3rd or 4th time, I received this error message on the first iteration of the code:

    putexcel_set_new(): 3010 attempt to dereference NULL pointer
    <istmt>: - function returned error
    r(3010);


    I am at a loss for what to do with this code--it seems there are older Statalist posts about this being a bug in previous versions of Stata, but there was a note that it ought to have been fixed for Stata 17. Any insight on how I am managing to break this code would be very helpful!

    Edited to add: I get the same error when I successfully produce a table (using inline code) and then try the table export mechanism under Statistics > Summaries, tables, and tests > Tables and collections > Build and style table.


    Very best,
    Maria
    Last edited by Maria Sundaram; 17 Aug 2022, 13:54.

  • #2
    Hi Maria,

    Have you found a solution? I am running into the same problem in Stata 17.0 for Windows (Windows Server 2016) and the only thing that seems to work is to restart Stata.

    Maxime

    Comment


    • #3
      I didn't, but have to admit I haven't been working on it! Restarting Stata will be my solution of choice until someone arrives on this thread to explain to me how I did this wrong.

      Comment

      Working...
      X