divishoot
08-11-2010, 09:21 AM
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 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