Hello,
I want to write a master do file to open several do files and run them. For this I have created the following master code (I am omitting parts of the paths to not reveal private information):
The above code is successful in opening the right do file. However, I am encountering the problem that in each do file that I want to run there is a "Configuration setting" written where I would have to specify several locals and globals. The configuration code in every do file is as follows:
Because of this my master do file breaks because stata is "unable to change to CSV_PATH" , since in each do file I want to run I have not specified the above macros manually.
I have tried the below code in my master do, but naturally the macros are overwritten by the generic ones that need to be configured in each do file (as the code above shows).
Is there a way I can automate changing these macros or override them from my master do? Or do I need to change them manually in each separate do file?
I want to write a master do file to open several do files and run them. For this I have created the following master code (I am omitting parts of the paths to not reveal private information):
Code:
global setup_path "C:\user\Project\Setup do" foreach year of numlist 2013/2019 { cd "$setup_path/`year'" foreach file in "d" "h" "p" "r" { do "`year'_cross_project_`file'_ver_2023_release1.do" }
Code:
local log_file "LOG_FILENAME" global csv_path "CSV_PATH" local stata_file "STATA_FILENAME"
I have tried the below code in my master do, but naturally the macros are overwritten by the generic ones that need to be configured in each do file (as the code above shows).
Code:
foreach year of numlist 2013/2019 { cd "$setup_path/`year'" foreach file in "d" "h" "p" "r" { local log_file "C:\user\project\Cross\Stata datasets\log_`year'_`file'" global csv_path "C:\user\project\Cross" local stata_file "C:\user\project\Cross\Stata datasets\`year'_`file'.dta" do "`year'_cross_project_`file'_ver_2023_release1.do" } }
Comment