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

INSERT

Name:
    INSERT (LET)
Type:
    Let Subcommand
Purpose:
    Insert the contents of one variable into another variable at a specified row location.
Description:
    The motivation for this command is the following. Suppose we have

      LET U1 = UNIFORM RANDOM NUMBERS FOR I = 1 1 10
      LET U2 = UNIFORM RANDOM NUMBERS FOR I = 1 1 5

    and we want to replace rows 6 to 10 of U1 with the values in U2. The INSERT command can be used do this.

    There are two cases for INSERT. In the above example, the values of U2 overwrite the current contents of U1. Alternatively, you can request that the values of U2 be added at the specified location but that the values of U1 are not overwritten. That is, the output variable will have rows 1 to 5 of U1, then rows 6 to 10 will have the U2 values, and then rows 11 to 16 will be rows 6 to 10 of U1.

    To specify that values of the first variable will be overwritten (the default), enter

      SET INSERT OVERWRITE ON

    To specify that the values of the second variable will be inserted and the values of the first variable will be shifted rather than overwritten, enter

      SET INSERT OVERWRITE OFF

    When the two variables are the same length and we are replacing corresponding rows of the first variable with the second variable, an appropriate SUBSET or FOR clause can typically be used. When the values of the second variable are added to either the beginning or end of the first variable, then the APPEND, EXTEND or COMBINE commands can be used. The INSERT command is useful when the contents of the second variable are inserted at an arbitrary location of the first variable.

Syntax:
    LET <y3> = INSERT <y1> <y2> <nloc>
    where <y1> is the first response variable;
                <y2> is the second reponse variable;
                <nloc> is a parameter that defines the starting row in <y1> where the <y2> values will be inserted;
    and       <y3> is the output variable.

    The <y1> and <y2> variables do not need to be the same length. The <y3> variable will be at least the same length as <y1> (it can be longer).

    If the value of <nloc> is non-positive or greater than the length of <y1> an error will be returned and <y3> will not be created.

    The <y3> variable can be the same as <y1>.

Examples:
    LET NLOC = 50
    LET Y1 = INSERT Y1 Y2 NLOC
Default:
    None
Synonyms:
    None
Related Commands:
    APPEND = Append a variable to the end of another variable.
    EXTEND = Extend a variable by another variable.
    COMBINE = Combine one or more variables and parameters into a single variable.
Applications:
    Data Management
Implementation Date:
    2020/02
Program 1:
     
    let u1 = uniform random numbers for i = 1 1 10
    let u2 = uniform random numbers for i = 1 1 10
    let nloc = 6
    let u1 = insert u1 u2 nloc
    print u1
        
    The following output is generated
    ---------------
                 U1
    ---------------
             0.5005
             0.8613
             0.0378
             0.0261
             0.4440
             0.5309
             0.1099
             0.2967
             0.6300
             0.6134
        
Program 2:
    let u1 = uniform random numbers for i = 1 1 10
    let u2 = uniform random numbers for i = 1 1 10
    set insert overwrite off
    let nloc = 6
    let u1 = insert u1 u2 nloc
    print u1
        
    The following output is generated
    ---------------
                 U1
    ---------------
             0.5005
             0.8613
             0.0378
             0.0261
             0.4440
             0.5309
             0.1099
             0.2967
             0.6300
             0.6134
             0.4243
             0.7259
             0.8519
             0.0964
             0.3348
        

Privacy Policy/Security Notice
Disclaimer | FOIA

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

Date created: 02/21/2020
Last updated: 02/21/2020

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