Announcement

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

  • Invalid file specification

    Hi,

    Does anyone has experienced this previously ? I am using StataMP 14 on win7 working with panel data.
    I save different files accordingly:

    tempfile r1r2
    save `r1r2'

    ----
    -----
    tempfile r3r4
    save `r3r4'

    Now, I would like to merge these two files

    use `r1r2' // executing this command I get "Invalid file specification" (I don't understand why it is invalid specification)
    merge CHILDID using `r3r4'

    Any help would be appreciated !


    Thanks!

  • #2
    Hello Tharshini,

    Welcome to the Stata Forum.

    I suggest you first define the working directory, before saving the file and merging data sets.

    Best,

    Marcos
    Best regards,

    Marcos

    Comment


    • #3
      Welcome to Statalist!

      I am going to start by assuming that your two tempfile commands were run within a do-file that you have open in the do-file editor.

      The important thing to keep in mind is that local macros (and similarly the temporary files defined with the tempfile command) vanish when the do-file within which they were created ends. So when the do-file ended, the local macros r1r2 and r3r4 were no longer defined. If your use command was run in a different do-file than the two tempfile commands, or run from the command window, then r1r2 and r3r4 were no longer defined. Your
      Code:
      use `r1r2'
      then was, after substituting nothing for `r1r2',
      Code:
      use
      which generates exactly the error message you encountered.

      A slightly more subtle way of having this happen can occur when the tempfile and use commands are in the same do-file, but instead of running the entire do-file at the same time, it is run by selecting a few lines at a time and running them. If you look carefully at your results window, you'll see that those few lines are copied into a temporary do-file and run, so even though all the commands are in the same window in the do-file editor, they are run as separate do-files.

      Comment


      • #4
        Hi,

        Thanks for a quick reply ! yes, your assumption is correct.
        It seems like your suggestion, i.e. to run all codes in one execution works well but it does not work when selecting few command lines at a time.

        Comment

        Working...
        X