
MATCHName:
This is a utility operation. That is, the index numbers are generally not of interest themselves but are used in subsequent computations. An alternative syntax supplies a third variable. Instead of returning an index, the MATCH command uses the index to extract the value corresponding to the index of this third variable. Generally, this is the ultimate goal (i.e., we would use the index to extract values of another variable).
where <x> is the variable containing a set of numbers; <val> is a number, parameter, or variable that will be matched against the values in <x>; <y> is a variable (of length equal to <val>) that contains the index (of <x>) where the match occurs; and where the <SUBSET/EXCEPT/FOR qualification> is optional. This syntax returns the index value.
where <x> is the variable containing a set of numbers; <val> is a number, parameter, or variable that will be matched against the values in <x>; <z> is a variable (of length equal to <x>) that contains the values to be extracted and placed in <y>; <y> is a variable (of length equal to <val>) that contains the values of <z> corresponding to the matched indices (of <x>); and where the <SUBSET/EXCEPT/FOR qualification> is optional.
This syntax returns values of
LET Y = MATCH X VALUE SUBSET X > 0 1 LET Y = MATCH X VALUE Z LET Y = MATCH X VALUE Z SUBSET X > 0
LET VAL = SEQUENCE 3 1 3 LET Y2 = MATCH Y VAL SET WRITE DECIMALS 3 PRINT VAL Y2
LET VAL = SEQUENCE 3 1 3 LET Z = SEQUENCE 10 1 1 LET Y2 = MATCH Y VAL Z SET WRITE DECIMALS 3 PRINT Y Z PRINT VAL Z2
Date created: 10/23/2001 