I don't know how to do what you want in STATA (never used it). But if you still haven't figured this out I could offer up some code to do it in R.
Hi,
I have about 20 files and I need to append 2 of them over and over.
Meaning append file0 to file1 and file1 to file2 and so on...
I wish to write a short loop code that will append each file to the next one.
I tried this-
forv y=0/10 {
use file`y', clear
append using file`y'+1
save file`y'new.dta
}
It didn't work and I don't really know how to fix it.
I thought about another code that will run but it's just wrong.
forv y=0/7 {
g x=`y'+1
forv x=1/8 {
use file`y', clear
append using file`x'
save file`y'new.dta, replace
}
Any ideas?
Help would be much appreciated
I don't know how to do what you want in STATA (never used it). But if you still haven't figured this out I could offer up some code to do it in R.
Hey there,
I think that this might work:
forv y=0/10 {
local k = `y' + 1
use file`y', clear
append using file`k'
save file`y'new, replace
}
Hope this helps!
Etienne
Thanks. I'll try it, hope it works
|
|