
INSERTName:
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
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
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.
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 nonpositive 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>.
LET Y1 = INSERT Y1 Y2 NLOC
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 u1The following output is generated  U1  0.5005 0.8613 0.0378 0.0261 0.4440 0.5309 0.1099 0.2967 0.6300 0.6134Program 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 u1The 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
NIST is an agency of the U.S. Commerce Department.
Date created: 02/21/2020 