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
How to detect data entry error: locating an observation that does not match any of the observations of a given set?Hi Statalist, Apologies for the vagueness of the question as I didn't know how to frame it better. H…
Issue with summing and averaging different columns/variablesHi, I'm fairly new to Stata so I apologize if my question is basic. I am essentially trying to creat…
generalised DID with two-way fixed modelDear researchers, I have unbalanced panel data for a set of firms for the year extends from 2000-201…
Right way to generate a dataset of estimates of treatment effect by year and their CI's as well as the year FEDear all, I want yearly coefficients of treat with their confidence intervals as well as the year f…
Exporting Percentage with asdocHi Attaullah Shah I am using asdoc command in stata it is very useful, and i am thankful for you. …
Subscribe to:
Post Comments (Atom)
0 Response to Loop same code through different directories
Post a Comment