Running CATS in a DO loop

A forum for questions and answers regarding the CATS cointegration procedure

Running CATS in a DO loop

Unread postby LionelR » Fri Jun 26, 2015 12:28 pm

Hi,

I need to run CATS procedures over a large number of datasets. I tried to achieve this with a DO loop, which has the following structure (simplified)

Code: Select all

source(noecho) "C:\Program Files (x86)\CATS2\CATS.src"

DO i = 1,20

   DEC STRING FNAME
   COMP FNAME = %dataset(i)+".xls"
   open data &FNAME
   data(format=xls,org=obs)
   calendar 1960
   allocate  2007:1

   @CATS(lags=1) 1960:1 2007:1
   #var1 var2 var3 var4 var5

<some other instructions>

END DO i

<some more instructions>


For some reason, the loop stops after CATS has been executed for the first time - it prints all the output, skips the remaining instructions in the DO block, and the executes what comes after it.

My guess is that somewhere in the CATS procedure, either a BREAK instruction occurs and triggers the loop to end, or some 'silent' error occurs (no such thing is being displayed). Is this possible? The procedure as such is working perfectly fine, and any other instructions I include in the loop are being executed without any problems, as long as I omit the CATS bit.

Thanks already,

Lionel
LionelR
 
Posts: 2
Joined: Fri Jun 26, 2015 5:39 am

Re: Running CATS in a DO loop

Unread postby TomDoan » Fri Jun 26, 2015 12:49 pm

It seems to work fine when I do it. I would recommend pulling the CALENDAR and ALLOCATE instructions outside the loop, since they're fixed across your data files. Have you tried this without the "some other instructions"? It's possible that they're interfering.
TomDoan
 
Posts: 7156
Joined: Wed Nov 01, 2006 5:36 pm

Re: Running CATS in a DO loop

Unread postby LionelR » Sat Jun 27, 2015 8:56 am

Thanks Tom for your quick reply.

I got it working now. The reason was that, using the out of the box CATS procedure, I had to manually end CATS at each iteration, which wasn't on my radar.
I worked around it by just skipping the "eternal CATS loop" in CATSmenu.src with a BREAK instruction at the very beginning of it. Seems to be working fine now.
LionelR
 
Posts: 2
Joined: Fri Jun 26, 2015 5:39 am


Return to CATS Questions

Who is online

Users browsing this forum: No registered users and 1 guest

cron