On Wed, 2 Feb 2011, Sergey N wrote:
Most probably due to very limited experience in programming and in
working
with gretl I'm
currently stuck with the following issue:
I have a data file with time series of monthly returns of AEX stocks from
1973 to 2007. By using
a script (attached and probably not the most elegant) I'm trying to
accomplish 2 things:
1. Count the number of "valid" stocks, that is stocks which have 12
months of returns data prior to t=0.
2. Only the stocks which fulfil the above mentioned criteria should be
copied to a new data file (appended).
Can anyone please explain to me how to accomplish #2 because just with
"store" instruction the data gets
overwritten.
I'm not sure if you want a separate data file for each 13-month
period. But if so (and if I've understood the rest of your
intentions), then something like this would do it:
loop j=1973..2006
smpl $j:1 $j:12+1
list OKstocks = null
loop foreach i r_AEX_INDE..r_ZEELAND_
n = sum(ok($i))
if n == 13
OKstocks = OKstocks $i
endif
if nelem(OKstocks) > 0
store "/Documents/data/stocks_valid_$j.gdt" OKstocks
endif
endloop
endloop
(Your outer loop cannot go to 2007 if you don't have a 2008:01
observation.)
Allin Cottrell