Announcement

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

  • .dta file corrupt. The file unexpectedly ended before it should have.- Problem

    Hi. New to stata.
    I imported a file using:

    import sas "filepath", clear case(lower)

    and then saved it using:

    save "filepath", replace.

    Then I tried to use the file using:

    clear all
    use"filepath"

    and got this result:

    .dta file corrupt
    The file unexpectedly ended before it should have.

    I'm clueless, any advice on the next steps. Thanks

  • #2
    Hi Emily, it's not clear to me why you got this error. You might take a moment to make sure that after:

    Code:
    import sas "filepath", clear case(lower)
    The data file was actually loaded correctly into memory. You might try looking through the data in the viewer, looking at the output of -describe- and so on. One possibility that comes to mind is that some character (probably a "whitespace" character that isn't actually displayed) appears in the SAS file, but turns out to be a file terminator character in the .dta file. I'm really just speculating though.

    The explanation might be a bit arcane, but I think there is a practical and straightforward next step: Use an interchange format. If you have access to SAS, I might load the data, then export the data as a .csv. Then use -import using- to read the .csv into Stata. The downside is that you may loose some meta data like value labels and the like, but the upside is that both of these software packages are designed to work with .csv files in a general sort of way, so you should be able to avoid the issue entirely.

    Comment


    • #3
      ...You might try looking through the data in the viewer,...
      I think Daniel means the Browser, not the Viewer.

      Comment


      • #4
        #3 is technically correct, though, perhaps, a bit pedantic. I am referring to the data browser, not the data viewer in #2.

        Comment


        • #5
          To paraphrase Bertrand Russell (The Good Citizen's Alphabet) slightly, a pedant is a person who prefers to be correct.

          Comment

          Working...
          X