Page 1 of 1

Please help. Data maneuvering problem

Posted: Sat Jun 14, 2014 4:47 pm
by mzhen
Hi there, I am using RATS to do my master's thesis and I got a problem.

The logic of my problem is:
Suppose I have 121 time series, and in each of the series there are 52 data points (so n=52). What I need is to extract the first data point (n=1) in each of the series and put them into a new series (e.g., series x).

Moveover, what if I want to do the same for the second data point (n=2, skipping n=1)?

I sort of know that it should involve an "if...else..." logic and/or some loops, but I could not figure it out myself.

Could someone help me with it. please?

Thank you very much!

P.S. English is my second language (as you probably already knew..), please forgive me for any inaccuracy and grammatical mistake...

Re: Please help. Data maneuvering problem

Posted: Sun Jun 15, 2014 10:34 am
by TomDoan
If they're all in the same data file, you may be able to just read them directly, which would be the simplest thing. If your data file looks like

x1 x2 x3 ...
nnn nnn nnn
nnn nnn nnn
nnn nnn nnn

then something like

data(format=xls,org=variables,top=2,nolabels) 1 121 data1 data2 data3 ...

will skip the first row of labels, the read the second row (first row of actual data) into series data1, the second row of data into series data2, etc. Depending upon what you want to do with it, you might prefer to read that into a VECT[SERIES] as in

dec vect[series] data(52)
data(format=xls,org=variables,top=2,nolabels) 1 121 data

which will define series data(1) as the first period, data(2) as the second, etc.

Re: Please help. Data maneuvering problem

Posted: Sun Jun 15, 2014 2:06 pm
by mzhen
Thank you so much Tom, I kind of figured it out myself last night.

I wrote a loop for it, I am not sure if the logic is right though...

do i=1,121
set x i i = y(i)(1)
end do i

I think in this way, the first data point in each of the y(i) series will be saved in x series. Is this right? It seems working ok on my program.

I got the inspiration from your replication of the VIRF (Hafner and Herwartz, 2006). Thank you so much, you are the best.