On 4/19/06, Ben Dwamena <[email protected]> wrote:
> I wish to empirically compare a linear and nonlinear model using
> sequentially 12 different datasets. How may I specify a looping
> procedure for the datasets in the manner of foreach var of varlist
> x1-x12........instead of writing a do-file for each dataset?
Assuming datasets are called data1.dta, data2.dta,
data3.dta....data12.dta, then something like...
forval x = 1/12{
use data`x', clear
regress [etc.]
nl [etc.]
[any other commands]
}
..would allow you to do this.
If your filenames are non-sequential then you would use a foreach loop...
foreach x in abc cde efg ghi ijk klm mno{
use data`x', clear
regress [etc.]
nl [etc.]
[any other commands]
}
HTH's
Neil
--
"Try to learn something about everything and everything about
something." - Thomas H. Huxley
Email - [email protected] / [email protected]
Website - http://slack.ser.man.ac.uk/
Blog - http://slack---line.blogspot.com/
Flickr - http://www.flickr.com/photos/slackline/
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/