I am new to Python, and am trying to execute a Stata do-file from Python, using MacOS.
Following advice in this question: Run Stata do file from Python
I tried the following code:
dofile = folder_path + "stata_dofile.do"
cmd = ["C:/Program Files (x86)/Stata14/StataSE-64", "do", dofile, variable1, variable2]
subprocess.call(cmd)
where "dofile" is the Stata do file I want to execute, and "variable1" and "variable2" are some string variables I want to feed to Stata.
This code works fine on Windows. But when I try to adapt it to the Mac as follows:
dofile = folder_path + "stata_dofile.do"
cmd = ["/Applications/Stata/StataMP.app", "do", dofile, variable1, variable2]
subprocess.call(cmd)
I get an error message "permission denied."
Following some other advice on this forum, I did manage to open the Stata app from Python on my Mac, using the following code:
cmd = ["/usr/bin/open", "/Applications/Stata/StataMP.app"]
subprocess.call(cmd)
But this only opens Stata, and I don't know how to modify the code to make it execute the do-file above.
Basically I have no idea what I'm doing. Would really appreciate any tips!