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
Reshape wide with missing observationsHello, I am trying to reshape wide the dataset below. Basically i would like the months (January th…
Specifying xtpmg optimal lags (2 3 1 2)dear community, i am having trouble specifying the optimal lags (2 3 1 2) chosen by AIC in my pmg mo…
How to standardize Stata variables format before using -append- ?I have around 40 files that I would like to append together. However, two variables named a12 and a1…
Renaming each variable label as a substring of old labelI have a set of variables v1 through v154 that I want to relabel by excluding the first 16 character…
How to check if value labels are consistently defined across multiple data sets using a loop?Hi, I'm trying to append some 35 data sets, one for each state. I used a loop to append them and sa…
Subscribe to:
Post Comments (Atom)
0 Response to Loop same code through different directories
Post a Comment