Announcement

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

  • Merging data but file not found

    Hello Statalists!

    I've been using STATA's merge function for a while, but this is something I've never encountered, so I was just wondering if anyone has any idea what should be done to solve the problem?

    So here's the issue: I was trying to merge data2 to data1 on two variables ID1 and ID2; both data files and the do file were saved in the same folder. My command was:

    merge 1:1 ID1 IDs using data2

    After running the command, I got an error message:

    file data2.dta not found
    r(601);

    I triple checked the file name and the directory and they were all correct. This was supposed to be an easy fix but I just couldn't figure out what was going on. Has anybody experienced anything similar to this issue? Any ideas would be greatly appreciated. Thank you so much in advance!

    P.S. I'm using STATA 15.1
    Last edited by WJ Wang; 08 Aug 2021, 01:14.

  • #2
    Your question amounts to your assertion that you haven't made any mistakes. That seems unlikely. These sorts of problems are common on Statalist and are almost always the result of user misunderstanding.

    Run the commands
    Code:
    pwd
    dir
    and post their output here using code delimiters [CODE] and [/CODE] as discussed in the Statalist FAQ linked to from the top of the page. Also, copy the code you ran from your do-file, starting with the use command that read in data1 and continuing through the merge command and paste it into a second CODE block.

    Comment


    • #3
      Originally posted by William Lisowski View Post
      Your question amounts to your assertion that you haven't made any mistakes. That seems unlikely. These sorts of problems are common on Statalist and are almost always the result of user misunderstanding.

      Run the commands
      Code:
      pwd
      dir
      and post their output here using code delimiters [CODE] and [/CODE] as discussed in the Statalist FAQ linked to from the top of the page. Also, copy the code you ran from your do-file, starting with the use command that read in data1 and continuing through the merge command and paste it into a second CODE block.
      Hi William,

      Thank you so much for your reply! I run the pwd command and turns out that the working directory on my laptop is not by default the active folder (which is still weird since I did not have to make the change before, nor on my office computer). I changed the working directory using the cd command and my merge command worked. Still not sure if I had to change the working directory everytime I merge files in the future, but this is definitely something I'd love to keep in mind.

      Thank you again for your suggestions!

      Comment

      Working...
      X