Sumif

Description

This function is used to calculate the sum of a (sub-)range of a vector that satisfies a specified condition. The sub-range can be discontiguous.

Syntax

 double Sumif(vector vd, string con$)

Parameters

vd

is a vector in which you want to calculate the sum.

con$

is the condition you use to find a sub-range. Double quotation ("") must be added for the condition.

Return

Return the sum of a sub-range in vector vd that satisfied the condition con$.

Example

newbook;
col(A) = data(1,32);
col(B) = col(A);
sumif(col(A),"col(A) > 5 && col(A) < 10")=;//should return 30
//simpler condition
sumif(col(A), "<10")=;

See Also

Countif, Averageif