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.
0 Response to Loop same code through different directories
Post a Comment