Dear all,
I am trying to loop through different subfolders. I have specified part of the directory with "cd".
`x' specifies the respective subfolder and "merged data" is the dataset I want to open (there is one dataset in each folder).
--------------------------------------------------------------------
After each iteration, Stata stops with an error such as "tech_similar (the subfolder) not found".
Then, I write the loop just with the subfolder that could not be found and run the code again - e.g.,
-------------------------------------
Now, it works.
From other posts I know that the loops might be sensitive to quotation marks, backslashes etc.
However, I cannot figure out the source of the error in this particular case.
Any ideas?
Best,
Florian
I am trying to loop through different subfolders. I have specified part of the directory with "cd".
`x' specifies the respective subfolder and "merged data" is the dataset I want to open (there is one dataset in each folder).
Code:
foreach x in forward_cites tech_similar tech_different tech .... { cd "K:/Gruppen/indoek/Florian/US EP/data/publ_level/" use "`x'/merged data.dta", clear ----commands--- }
After each iteration, Stata stops with an error such as "tech_similar (the subfolder) not found".
Then, I write the loop just with the subfolder that could not be found and run the code again - e.g.,
Code:
foreach x in tech_similar { ....
Now, it works.
From other posts I know that the loops might be sensitive to quotation marks, backslashes etc.
However, I cannot figure out the source of the error in this particular case.
Any ideas?
Best,
Florian
Comment