I think the reason this fails is that the condition should result in a boolean scalar, whereas here it is a series of booleans.In this case you can use the ternary operator to set up a conditional assignment (see User Guide p. 140):
<hansl>
open australia.gdt
series E_hp = E - hpfilt(E, 1600)
series E_reg1= (E > E_hp) ? E : NAseries PAUreg1 = (E > E_hp) ? PAU : NAseries PUSreg1 = (E > E_hp) ? PUS : NA
<hansl>
HTH,Jan Annaert
UNIVERSITEITANTWERPEN | Faculty of Applied Economics (TEW) | Dept. Accounting & Finance
Room S.B.335 | Prinsstraat 13 | B-2000 Antwerp | Belgium
Phone +32 32654163 |Fax +32 32654064https://www.uantwerp.be/en/staff/jan-annaert/
http://ssrn.com/author=143473
From: Henrique Andrade <henrique.coelho@gmail.com>
Reply-To: "gretl-users@lists.wfu.edu" <gretl-users@lists.wfu.edu>
Date: woensdag 25 maart 2015 17:15
To: "gretl-users@lists.wfu.edu" <gretl-users@lists.wfu.edu>
Subject: [Gretl-users] "If-Else" syntax help
Dear Gretl community,
I'm not a good "if-else" user so I need a little help. What's wrong with the following code?
<hansl>
open australia.gdt
series E_hp = E - hpfilt(E, 1600)
if E > E_hpseries E_reg1 = Eseries PAUreg1 = PAUseries PUSreg1 = PUSelseseries E_reg1 = NAseries PAUreg1 = NAseries PUSreg1 = NAendif
<hansl>
When I execute it I get the messages: "error evaluating 'if'" "Error executing script: halting".
Best regards,Henrique Andrade
_______________________________________________
Gretl-users mailing list
Gretl-users@lists.wfu.edu
http://lists.wfu.edu/mailman/listinfo/gretl-users