SED navigation bar go to SED home page go to Dataplot home page go to NIST home page SED Home Page SED Staff SED Projects SED Products and Publications Search SED Pages
Dataplot Vol 2 Vol 1

INDEX FIRST MATCH

Name:
    INDEX FIRST MATCH (LET)
Type:
    Let Subcommand
Purpose:
    Return the index (i.e., the row number) of either the first or last matching (or non-matching) entries for two arrays.
Description:
    It may sometimes be convenient to determine the index of the first row where two distinct arrays have the same value. Likewise, it may be convenient to determine the index of the last row where they have the same value. If no match is found, an index of 0 is returned.

    You can also return the index of the first or last row where the two arrays have different values. If all rows have the same value, then an index of 0 is returned.

    The two arrays do not need to be same size. For the case where the two arrays are of different sizes and we are looking for the first row where they do not have the same value, the index returned is MIN(N1,N2) + 1 where N1 and N2 are number of rows for the two arrays. For the case where the two arrays are of different sizes and we are looking for the last row where they do not have the same value, the index returned is MAX(N1,N2) where N1 and N2 are number of rows for the two arrays.

Syntax 1:
    LET <par> = INDEX FIRST MATCH <y1> <y2>
                            <SUBSET/EXCEPT/FOR qualification>
    where <y1> is the first response variable;
                <y2> is the second response variable;
                <par> is a parameter containing the returned index;
    and where the <SUBSET/EXCEPT/FOR qualification> is optional.

    This is for the case where we are looking for the index where the two arrays first have the same value.

Syntax 2:
    LET <par> = INDEX LAST MATCH <y1> <y2>
                            <SUBSET/EXCEPT/FOR qualification>
    where <y1> is the first response variable;
                <y2> is the second response variable;
                <par> is a parameter containing the returned index;
    and where the <SUBSET/EXCEPT/FOR qualification> is optional.

    This is for the case where we are looking for the index where the two arrays last have the same value.

Syntax 3:
    LET <par> = INDEX FIRST NOT MATCH <y1> <y2>
                            <SUBSET/EXCEPT/FOR qualification>
    where <y1> is the first response variable;
                <y2> is the second response variable;
                <par> is a parameter containing the returned index;
    and where the <SUBSET/EXCEPT/FOR qualification> is optional.

    This is for the case where we are looking for the index where the two arrays first have different values.

Syntax 4:
    LET <par> = INDEX LAST NOT MATCH <y1> <y2>
                            <SUBSET/EXCEPT/FOR qualification>
    where <y1> is the first response variable;
                <y2> is the second response variable;
                <par> is a parameter containing the returned index;
    and where the <SUBSET/EXCEPT/FOR qualification> is optional.

    This is for the case where we are looking for the index where the two arrays last have different values.

Examples:
    LET A = INDEX FIRST MATCH Y1 Y2
    LET A = INDEX FIRST MATCH Y1 Y2 SUBSET TAG > 1
    LET A = INDEX LAST MATCH Y1 Y2
Note:
    Dataplot statistics can be used in a number of commands. For details, enter

Default:
    None
Synonyms:
    None
Related Commands:
    PERCENT AGREE = Compute the percentage of values that agree in two response variables.
    PERCENT DISAGREE = Compute the percentage of values that disagree in two response variables.
Applications:
    Data Manipulation
Implementation Date:
    2011/11
Program:
     
    read y1 y2
     23 19
     31 31
     18 42
     22 10
     26 26
     11 14
    end of data
    .
    let n = size y1
    let indx = sequence 1 1 n
    set write decimals 0
    .
    let a1 = index first match y1 y2
    let a2 = index last  match y1 y2
    let a3 = index first not match y1 y2
    let a4 = index last  not match y1 y2
    .
    set write decimals 0
    print indx y1 y2
    print a1 a2 a3 a4
        
    The following output is generated.
     
    ---------------------------------------------
               INDX             Y1             Y2
    ---------------------------------------------
                  1             23             19
                  2             31             31
                  3             18             42
                  4             22             10
                  5             26             26
                  6             11             14
    
    
     PARAMETERS AND CONSTANTS--
    
         A1      --         2
         A2      --         5
         A3      --         1
         A4      --         6
        

Privacy Policy/Security Notice
Disclaimer | FOIA

NIST is an agency of the U.S. Commerce Department.

Date created: 12/06/2011
Last updated: 11/16/2015

Please email comments on this WWW page to alan.heckert@nist.gov.