Hi,
I have a set of datafiles - file_1 to file_10. Each file looks like the following:
I wanted to run a loop that gets by each file, using the integ function to numerically integrate y on x and generate a new column with the value of the integrals, called a.
I wrote a loop like this:
forvalues i = 1/10{
use file_`i', clear
integ y x, generate(a)
save file_`i', replace
}
Curiously enough, I can't run this even if I can run the inner commands by themselves. The error I get is "no observations", r(2000). Can you please tell me where I am going wrong?
Thanks!
Haaris
I have a set of datafiles - file_1 to file_10. Each file looks like the following:
Y | X |
9 | 1 |
15 | 2 |
6 | 3 |
23 | 4 |
I wrote a loop like this:
forvalues i = 1/10{
use file_`i', clear
integ y x, generate(a)
save file_`i', replace
}
Curiously enough, I can't run this even if I can run the inner commands by themselves. The error I get is "no observations", r(2000). Can you please tell me where I am going wrong?
Thanks!
Haaris
Comment