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

MERGE

Name:
    MERGE (LET)
Type:
    Let Subcommand
Purpose:
    Merge two data sets.
Description:
    This command operates on two sets of data to generate a third merged set of data.

    For each of the two data sets, we define "match" variables and "carry" variables. We assume that both sets of data have the same number of match and the same number of carry variables.

    The number of match variables is specified by entering the command (before the MERGE command)

      SET MERGE MATCH VARIABLES <value>

    The number of carry variables is specified by entering the command (before the MERGE command)

      SET MERGE CARRY VARIABLES <value>

    If these commands are not entered, the default is one match variable and one carry variable. Currently, a maximum of three match variables and eight carry variables are allowed.

    The merge is performed as follows:

    1. Loop through data set one. For each row, extract the values of the match variables for data set one.

    2. For a given row of data set one, loop through data set two and find all rows where the values of the data set two match variables are equal to the given row of data set one match variables. These define "merged" rows.

    3. For each each "merged" row, we output the value of the match variables (which will be the same for data set one and data set two), then the values of the carry variables for data set one, and finally the values of the carry variables for data set two.

    Note that values of the "match" variables which exist for only one of the data sets are omitted in the merged data set.

Syntax:
    LET <mz1> ... <mzk> <cz1> ... <cz2l> = MERGE <mx1> ... <mxk> <cx1> ... <cxl>
                            <my1> ... <myk> <cy1> ... <cyl>
                            <SUBSET/EXCEPT/FOR qualification>
    where <mx1> ... <mxk> are the k match variables for data set one;
                <cx1> ... <cxl> are the l carry variables for data set one;
                <my1> ... <myk> are the k match variables for data set two;
                <cy1> ... <cyl> are the l carry variables for data set two;
                <mz1> ... <mzk> are the k match variables for the merged data;
                <cz1> ... <cz2l> are the 2*l carry variables for the merged data;
    and where the <SUBSET/EXCEPT/FOR qualification> is optional.

    If there are NMATCH match variables and NCARRY carry variables, then there will be NMATCH + 2*NCARRY variables to the left of the "=" and 2*(NMATCH + NCARRY) to the right of the "=". on two variables.

Examples:
    SET MERGE MATCH VARIABLES 2
    SET MERGE CARRY VARIABLES 1
    LET INST SRC ZP1 ZP2 = MERGE INST1 SRC1 P1 INST2 SRC2 P2
    LET INST SRC ZP1 ZP2 = MERGE INST1 SRC1 P1 INST2 SRC2 P2 ...
                            SUBSET INST1 > 2
Note: Default:
    None
Synonyms:
    None
Related Commands:
    MERGE = Merge library function.
    SORT = Sort the elements of a variable.
    SORTC = Sort the elements of a variable and carry one or more variables along.
    CODE = Generate a coded variable.
    SEQUENCE = Generate a sequence of numbers.
Applications:
    Data Management
Implementation Date:
    2008/9
Program:
     
    DIMENSION 100 COLUMNS
    .  READ DATA SET 1  - 2 GROUP VARIABLES, A BINOMIAL PROPORTION AND
    .                     A CORREPSONDING SAMPLE SIZE
    READ INST1  SRC1  P1  N1
     1   1   0.81  40
     1   2   0.92  40
     1   3   0.62  50
     2   1   0.45  25
     2   2   0.98  25
     2   3   0.74  25
    END OF DATA
    .  READ DATA SET 2  - 2 GROUP VARIABLES, A BINOMIAL PROPORTION AND
    .                     A CORREPSONDING SAMPLE SIZE
    READ INST2  SRC2  P2  N2
     1   2    0.40  20
     2   2    0.32  20
     1   1    0.29  30
     2   1    0.18  30
     1   3    0.81  40
     2   3    0.66  40
    END OF DATA
    . NOW CREATE A MERGED DATA SET AND PERFORM A DIFFERENCE OF PROPORTIONS
    . HYPOTHSES TEST
    SET MERGE MATCH VARIABLES 2
    SET MERGE CARRY VARIABLES 2
    LET INST SRC X1 ZN1 X2 ZN2 = MERGE INST1 SRC1 P1 N1 INST2 SRC2 P2 N2
    LET ALPHA = 0.05
    FEEDBACK OFF
    SET WRITE FORMAT 2F5.0,2(F7.2,F5.0)
    PRINT INST SRC X1 ZN1 X2 ZN2
    LET PVAL = DIFFERENCE OF PROPORTION HYPOTHESIS TEST  X1 ZN1 X2 ZN2 ALPHA
    SET WRITE FORMAT
    SET WRITE DECIMALS 3
    PRINT PVAL
        
    The following output is generated.
       1.   1.   0.81  40.   0.29  30.
       1.   2.   0.92  40.   0.40  20.
       1.   3.   0.62  50.   0.81  40.
       2.   1.   0.45  25.   0.18  30.
       2.   2.   0.98  25.   0.32  20.
       2.   3.   0.74  25.   0.66  40.
    
     VARIABLES--PVAL    
    
              0.000
              0.000
              0.051
              0.028
              0.000
              0.497
        

Date created: 1/21/2009
Last updated: 1/21/2009
Please email comments on this WWW page to alan.heckert@nist.gov.