On Fri, 6 Sep 2024, Summers, Peter wrote:
Hi all,
When trying to use the console to create a new variable, I get an
error message after typing "if (female == 1)" saying "error
evaluating 'if'". [...]
To add just a little to what others have said: in hansl a valid
instance of
if <condition>
must produce a scalar result, telling the interpreter to go ahead
(if non-zero) or not (if zero), into a block of statements ended by
"endif".
If "female" is a series with both 0s and 1s then the result is not a
scalar and so can't tell gretl what to do.
However, it's OK for a ternary query such as "(female == 1) ?" to
produce a scalar, series or matrix result, depending on the context.
Allin