Announcement

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

  • Reopening do file. Source file path not found r(601).

    I am running STATA 15/IC. I am working off a data set that is saved on a server, and every time I reopen my do file to continue working, it gives me this error:

    Code:
    use "//Volumes/asis/ASIS Documents/Current students/Summer Students 2018/Colin/Data Cleaning/Clinical Measures/Y1-5 PBQ DVA VOMS/Y1-4 PBQ DVA VOMS.dta"
    
    file //Volumes/asis/ASIS Documents/Current students/Summer Students 2018/Colin/Data Cleaning/Clinical Measures/Y1-5 PBQ DVA VOMS/Y1-4 PBQ DVA VOMS.dta not found
    r(601);
    As such, I have to manually re enter the file path each time I open my do file for it to run properly. I am very new to STATA, so this could definitely be something super simply that I am missing.

    Thanks!

  • #2
    I actually figured out the problem. The two computers I work on are a Mac and a PC, so the file path changes slightly between each one. To update the question, does anyone know of the fix this?

    Comment


    • #3
      Welcome to Statalist.

      See help creturn for the description of c(os), and then use it - in code similar to the following - to set a local macro to the correct path, which you then have in your use command, and anywhere else you might need it.
      Code:
      . if "`c(os)'"=="MacOSX" local msg "This is running on a Mac"
      
      . else local msg "This is not running on a Mac"
      
      . display "`msg'"
      This is running on a Mac
      By the way, since you are running on Windows, it may help you to know that the backslash character
      Code:
      \
      has meaning to Stata: it will prevent the interpretation of any following character that has a special meaning to Stata, in particular
      Code:
      `
      will not be interpreted as indicating a reference to a macro.

      But all is not lost: Stata will allow you to use the forward slash character in path names on any operating system, and on Windows will take care of doing what must be done to appease Windows.
      Code:
      . local prefix batch42
      
      . display "Q:\HOME\`prefix'_filename"
      Q:\HOME`prefix'_filename
      
      . display "Q:/HOME/`prefix'_filename"
      Q:/HOME/batch42_filename

      Comment


      • #4
        Code:
        ssc install fastcd
        This is how I deal with this issue. This program keeps a list of folder locations, which you can set per machine.
        So set pwd to the folder with your files on each machine, and type e.g.,

        Code:
        c cur myverylongfolderpath
        Then in your do file, change commands for opening files to


        Code:
        c myverylongfolderpath
        use "Y1-4 PBQ DVA VOMS.dta"

        Comment


        • #5
          Thank you all very much! I got it figured out with my IT guy at work

          Comment

          Working...
          X