Announcement

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

  • (r601) error - File not found during code replication

    Hello,

    I am currently trying to replicate a Stata code but I am having trouble at the very beginning. The beginning of the code goes:

    Code:
    set more off
    clear all
    
    global MatchingDoFiles   "C:\Users\clero\OneDrive\Documenti\Master's thesis\STATA\test\ABE_algorithm_code\codes"            
    global datadirA             "C:\Users\clero\OneDrive\Documenti\Master's thesis\STATA\test\1850_census"                
    global datadirB             "C:\Users\clero\OneDrive\Documenti\Master's thesis\STATA\test\1880_census"              
    global outdir              "C:\Users\clero\OneDrive\Documenti\Master's thesis\STATA\test\Cleaned_data"                        
    global matchdir          "C:\Users\clero\OneDrive\Documenti\Master's thesis\STATA\test\Matched_data"                            
    
    foreach state in NewYork {
    
    use `"$datadirA\1850_NewYork.dta"', clear
    }
    (I already adapted the code by deleting all other states except New York; however, the error message was the same with all 50 US states, as it is in the original code.)

    And this is where I run into trouble. I have adapted the file paths to replect my computer's file paths, as instructed. However, it cannot seem to find them, as this message pops up:

    Code:
    file C:\Users\clero\OneDrive\Documenti\Master's
        thesis\STATA\test\1850_census\1850_NewYork.dta not found
    r(601);
    I do not understand how it cannot find this file, which does exist and works perfectly well when opened in another Stata window. Is the use of
    Code:
    global
    incorrectly done?

    I have also tried defining the working director as ""C:\Users\clero\OneDrive\Documenti\Master's thesis\STATA\test", but this makes no difference. I feel like the error is probably to to a simple syntax error, but I can't figure out what.

    For further information, I use Stata/SE 17.0 and I am quite a new user.

    Please let me know if you have an idea of what went wrong or if you need further information. Thank you for your help!

  • #2
    I do not understand how it cannot find this file, which does exist and works perfectly well when opened in another Stata window
    1. Double-click that file in Explorer to open in Stata.
    2. Then press PageUp to bring the -use- command to the command window.
    3. Copy the command to your do file below the one that is already there.
    4. Compare character-by-character.

    Typically the difference will be in something minor, like a different kind of apostrophe used, which is not clearly visible to the human eye, but computers are sensitive to. Like in this example:
    Code:
    clear
    
    input tеst
    1
    end
    
    list test
    Click image for larger version

Name:	variable_test_not_found.png
Views:	1
Size:	2.5 KB
ID:	1715823



    If that doesn't help, consider having a firm copy (away from OneDrive, or other similar virtual folders software) and retrying there.

    Hope this helps, Sergiy

    Comment

    Working...
    X