On Fri, 24 Apr 2015, Henrique Andrade wrote:
Dear Gretl Team,
I would like to know if there exists a way to use "dataset" command inside
a function. Please take a look at my code:
<hansl>
open australia.gdt
function list anualizar(series x)
dataset compact 1 last
end function
eval anualizar(PAU)
</hansl>
The answer is No. The rule with gretl functions is that they cannot
have arbitrary side effects. They can return a value, and they can
change the values of arguments given in "pointer" form, but that's
it. They can't mash up your dataset.
Notice that in your example, the series argument is bogus: it
implies that something is being done with a particular series, but
if the "dataset" command were allowed in a function it would
actually transform the entire dataset.
It's possible to do something that's related, without breaking the
rules. If a function is given a series or list argument, you can
turn that into a matrix, then process the matrix however you want,
and return the result as a matrix. Thus, given a quarterly series
one could return an annualized version in the form of a column
vector.
Allin