Page 1 of 1
DOFOR LOOP
Posted: Tue Apr 10, 2012 9:06 pm
by wljames
I am trying to create a dofor loop for series. The following is my attempt:
I have read the data in correctly. The data is panel data from the Applied Econometric Times Series Text - exchange rates
dofor i = australia canada france germany japan netherlands uk us
set lx = log(i)
At this point I check the Series Windows in RATS 8.1 and lx has no observations. What am I doing wrong?
Thanks!
Re: DOFOR LOOP
Posted: Wed Apr 11, 2012 8:18 am
by TomDoan
wljames wrote:I am trying to create a dofor loop for series. The following is my attempt:
I have read the data in correctly. The data is panel data from the Applied Econometric Times Series Text - exchange rates
dofor i = australia canada france germany japan netherlands uk us
set lx = log(i)
At this point I check the Series Windows in RATS 8.1 and lx has no observations. What am I doing wrong?
Thanks!
i at that point is a number, representing a series but not parsed as one. You need to use
set lx = log(i{0})
to get the proper results.
Re: DOFOR LOOP
Posted: Wed Apr 11, 2012 9:05 am
by wljames
dofor i = australia canada france germany japan netherlands uk us
set lx = log(i{0})
When I execute the above lx still have zero observations. I checked another source and it suggested the following, but I do not know what is meant by [series]
log [series]i / lx
I am a beginner and I respectfully request anyone's help. Thank you!

Re: DOFOR LOOP
Posted: Wed Apr 11, 2012 10:31 am
by moderator
You don't need or want the type modifier (the [series] tag) on the LOG instruction. You would just do:
log i / lx
For an instruction like this, RATS knows that the first parameter has to be a series, so if you supply an integer, it automatically treats it as a series number.
RATS can't make that assumption when an integer appears on the right side of a SET instruction (it has no way of knowing that you mean for an integer to refer to a series number). That's why you would need to add lag notation or a type modifier:
set lx = log(i{0})
or
set lx = log([series] i)
Any of the three above commands is correct. If you are still getting missing values in all entries for LX using any of these, then the source of the problem lies elsewhere. The first step would be to check the original series. For example, do:
print / australia canada france germany japan netherlands uk us
Do the data look correct? If not, work back from there to see where you've made a mistake.
Regards,
Tom Maycock
Estima