On Wed, 18 Apr 2012, Henrique Andrade wrote:
Is there a way to circumvent the fact that we can not use the
command
"dataset" inside a function?
No. By design, functions are supposed to take the dataset as
given by the caller, and not mess with it.
Please take a look in the following code:
<hansl>
function series TESTE (series Y, int tamanho)
dataset addobs tamanho
string nome = argname(Y)
print nome
gnuplot @nome Y_hat_$P_1_$Q --time-series --with-lines --output=display
end function
dataset clear
open fedstl.bin
data exbzus usphci
TESTE(exbzus,48)
</hansl>
You have to do the "addobs" part outside of the function. But
note that this sort of function would likely be problematic
anyway. What happens if I do
TESTE(exbzus,48)
TESTE(usphci,48)
As written, I'd end up with 96 added observations: are there
plausible conditions under which that's what I'd actually
want? I don't know.
Allin Cottrell