Announcement

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

  • Mac constantly getting an error when trying to create a directory or retrieve data

    Hi,

    I'm having trouble creating a directory for my do file or even retrieving the data I need to use. I believe the problem is with my Mac because before it was having an error even finding the pathway to my documents folder, so I had to change it to the desktop for it to half-way work.

    These are my commands:

    clear all
    prog drop _all
    capture log close
    set more off

    global datadir "/Users⁩/C/desktop/ProblemSets"
    global logdir "/Users/C/desktop/ProblemSets"

    log using "$logdir/Ps1 log_new.smcl", replace
    use "$datadir/HIV Testing Data.dta", clear

    This is the result that appears:

    . clear all

    . prog drop _all

    . capture log close

    . set more off

    .
    . global datadir "/Users⁩/C/desktop/ProblemSets"

    . global logdir "/Users/C/desktop/ProblemSets"

    .
    . log using "$logdir/Ps1 log_new.smcl", replace
    --------------------------------------------------------------------------------------------------------
    name: <unnamed>
    log: /Users/C/desktop/ProblemSets/Ps1 log_new.smcl
    log type: smcl
    opened on: 23 Sep 2019, 17:19:58

    . use "$datadir/HIV Testing Data.dta", clear
    file /Users⁩/C/desktop/ProblemSets/HIV Testing Data.dta not found
    r(601);

    end of do-file
    Last edited by Karine Pole; 23 Sep 2019, 16:39.

  • #2
    Does the file /Users⁩/C/desktop/ProblemSets/HIV Testing Data.dta already exist?

    Breaking it down a bit...

    Can you:

    Code:
    sysuse auto, clear
    save  `" /Users⁩/C/desktop/ProblemSets/test.dta"', replace
    
    u  `" /Users⁩/C/desktop/ProblemSets/test.dta"', clear
    without issues? If so, then it seems this is a problem with your paths. Check the paths and then add compound quotes to make sure nothing is biting in your macros. Example:

    Code:
    global datadir `"/Users⁩/C/desktop/ProblemSets/"'   // <--add this last slash and the double quotes to help protect your path
    use `"$datadir/HIV Testing Data.dta"', clear  // same
    I dont see a -mkdir- command to 'make' a directory - is it possible that you are expecting Stata to make the ProblemSets directory on the fly because it does not exist? You'd need to make this folder (or use -mkdir-).



    Eric A. Booth | Senior Director of Research | Far Harbor | Austin TX

    Comment


    • #3
      Originally posted by eric_a_booth View Post
      Does the file /Users⁩/C/desktop/ProblemSets/HIV Testing Data.dta already exist?

      Breaking it down a bit...

      Can you:

      Code:
      sysuse auto, clear
      save `" /Users⁩/C/desktop/ProblemSets/test.dta"', replace
      
      u `" /Users⁩/C/desktop/ProblemSets/test.dta"', clear
      without issues? If so, then it seems this is a problem with your paths. Check the paths and then add compound quotes to make sure nothing is biting in your macros. Example:

      Code:
      global datadir `"/Users⁩/C/desktop/ProblemSets/"' // <--add this last slash and the double quotes to help protect your path
      use `"$datadir/HIV Testing Data.dta"', clear // same
      I dont see a -mkdir- command to 'make' a directory - is it possible that you are expecting Stata to make the ProblemSets directory on the fly because it does not exist? You'd need to make this folder (or use -mkdir-).


      Thank you for the response.

      Yes, that file and the ProblemSets directory already exist.

      I tried the code, and unfortunately STATA is giving me an error code that it can't be opened.

      In reference to the second code provided, I'm getting the same r(603); error. I don't know why it refuses to work.

      Comment


      • #4
        I noticed that there is an extra space in the code I pasted into my previous comment (
        Code:
        `" /Users⁩/C/desktop/ProblemSets/test.dta"'
        should be
        Code:
        `"/Users⁩/C/desktop/ProblemSets/test.dta"'
        ). Assuming that isnt the source of your 603 error, can you save files to that same directory using other applications? Also, try right-clicking on the folder and checking your folder permissions. If Stata is the only application that cannot write files to that (or any?) directory then I would contact Stata tech support and/or try reinstalling Stata.
        Eric A. Booth | Senior Director of Research | Far Harbor | Austin TX

        Comment

        Working...
        X