Announcement

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

  • Unusual Reshape Error: tmp file cannot be modified or erased

    Dear Statalisters:

    I've come across a problem I've not yet experienced before. I'm trying to reshape a (very) large file into wide format--it's got about 2 million observations and I'm reshaping wide for about 300 values across 80-some variables. I was able to do it on my desktop, but now I'm in "work-from-home" mode on my laptop thanks to the plague and I'm getting an error on my laptop.

    Here's what my code looks like:

    Code:
    use pubid uid child_agemo_1_-child_agemo_80_ using ///
    "C:\Users\jonat\Documents\OneEventPaper\befsplit.dta", clear
    
    sleep 5000
    
    reshape wide child_agemo_1_-child_agemo_80_, i(pubid) j(uid)
    
    sleep 5000
    And here is the error:
    Code:
    file C:\Users\jonat\AppData\Local\Temp\ST_1338_000002.tmp cannot be modified or erased; likely cause is read-only directory or file
    Does anyone have a way around this? I saw previous posts here suggesting that I add the sleep command to try and slow things down, but it's not helping. It's just very strange; it worked on my desktop with Stata 15, and now I'm using Stata 16 on my laptop and it's giving me an error message I can't figure out. Does anyone have a fix for this?

    Thank you for your time,
    Jonathan

  • #2
    Have you tried starting small and working up? Try reshaping 10 variables and see if the same error recurs. Try reshaping all the variables on 10,000 observations and see if the same error recurs.

    If it does, the problem seems likely to lie in the configuration of your temporary storage. If instead one or the others works, then try dividing up your data into several pieces, reshaping the pieces separately, then merging or appending the reshaped datasets.

    Comment


    • #3
      So your theory fits with a bunch of things I've tried. I have:
      1) Cut down the number of variables
      2) Deleted some files on my hard drive that were taking up a lot of space and I didn't need
      3) Cleared out my temporary files.

      One of those three things must have done it, because it worked when I did it. I'm not sure exactly what did it. Do you have a sense of what might have been the deciding factor?

      Comment


      • #4
        My guess would be a combination of 2 and 3 - lack of space on disk. That's consistent with the code working on your desktop system, and with the error message - not the guess about the file or directory being read only, but with the more general interpretation of "filesystem problems".

        Comment


        • #5
          Thanks. It's strange, because I've read about this error message having to do with not being about to overwrite files quickly enough, so it is locked, but it really doesn't seem like that was the problem here. The message doesn't quite seem to correspond to the problem.

          Comment


          • #6
            I encountered this same problem recently when reshaping a small dataset (3 variables, 40 observations). Deleting my temporary files seems to have fixed it.
            Associate Professor of Finance and Economics
            University of Illinois
            www.julianreif.com

            Comment

            Working...
            X