Hello,
I have 10 network directories containing a number of .dta files. The data files, in each directory, all have the same name, so I can run the come code, pointing to each directory, without having to change the code. The only thing I need to change is the directory. The .dta files in each directory are the same in each folder, with the exception of a population.dta - this is different in each folder: It has a different population projection - but is in the same format as every other population.dta, and the same name. The directories follow the same naming convention , c:/drive/year1 c:/drive/year2 c:/drive/year3 etc.
At the moment I run the code separately, once for each directory, I just cancel out the directories I don't need each time.
I was wondering if there was a way to use a loop to do this, for example
local directories (list of directories)
foreach d of local directories {
}
However, I have not got further than the above!
There may be better ways of doing this work - but this is the structure I have inherited and would like to automate via a loop this bit of the work, as it can take several hours for the code to run through a directory at a time.
Related Posts with Loop same code through different directories
jwdid: DID using ETwFEDear all thanks to prof. Baum a new command is ready to use. jwdid implements the did estimator prop…
Merge identifier and date within rangeHi all, I would like to merge two datasets by identifier and date within range dataset A: accountnum…
Multiple correspondence analysis predictionHi all I am trying to make a multiple correspondence analysis in Stata using the Burt approach. My a…
Margins plots and significanceHello Stata Folk, I'm running a panel regression with squared interaction terms. I want to confirm …
Error message with 'collect export' in Stata 17Hello, I have a large descriptive Table 1 that I'd like to try to export to an Excel file for a man…
Subscribe to:
Post Comments (Atom)
0 Response to Loop same code through different directories
Post a Comment