Am 24.11.2015 um 15:27 schrieb Alessandro Astuti:
Hi, is there an excel's sumif equivalent in gretl?
Not directly as a function with its own name (I think), but it's fairly
easy to get the effect. If x is your series, and you want to consider
values above 10 only, then you can do something like:
scalar mysum = sum( (x > 10) * x)
(If x is not a series but a matrix/vector, you probably would have to
replace the "*" operator with ".*".)
Background: "(x>10)" produces a series with 1 at those observations
where the condition is true, and 0 else. If you want to avoid the
multiplication for some reason, you could do it in two lines:
series x2 = (x > 10) ? x : 0
scalar mysum2 = sum(x2)
which copies zeros to x2 wherever x is not greater than 10.
And of course you could wrap this into your own user-defined function
sumif if you really need to.