On Thu, 11 Oct 2018, Filipe Rodrigues da Costa wrote:
Hi all,
I'm trying to delete several series with a loop like this:
<gretl>
loop i=1 ..100
if sum(ok(series$i)) < 20
delete series$i
endif
endloop
</gretl>
Let's say I have series1, series2, ...,series100. I want to delete all
series with less than 20 observations. But, Gretl doesn't allow this
kind of massive deletion. Any ideas on how can I check over several
series and delete those whic don't fit the criteria?
Many thanks in advance
You can create a list of series that satisfy (or do not satisfy)
some criterion, then delete the listed series in one go. Here's an
artificial example where we create 30 random normal series and then
delete all those with a maximum value greater than 2.7:
<hansl>
nulldata 50
matrix X = mnormal(50, 30)
list Del = null
loop i=1..30 -q
# create series from col i of X
idx = genseries(sprintf("x%d", i), X[,i])
if maxc(X[,i]) > 2.7
# schedule for deletion
Del += idx
endif
endloop
# show which ones will be deleted
list Del print
# and trash them
delete Del
varlist
</hansl>
Allin Cottrell