## INSERT Function

**inserts one matrix inside another**
**INSERT(** *x*, *y*, row<, column>**)**

The inputs to the INSERT function are as follows:
*x*
- is the target matrix.
It can be either numeric or character.

*y*
- is the matrix to be inserted into the target.
It can be either numeric or character,
depending on the type of the target matrix.

*row*
- is the row where the insertion is to be made.

*column*
- is the column where the insertion is to be made.

The INSERT function returns the result of inserting
the matrix *y* inside the matrix *x* at the place
specified by the *row* and *column* arguments.
This is done by splitting *x* either horizontally
or vertically before the row or column specified
and concatenating *y* between the two pieces.
Thus, if *x* is *m* rows by *n* columns, *row* can range
from 0 to *m*+1 and *column* can range from 0 to *n*+1.
However, it is not possible to insert in both
dimensions simultaneously, so either *row*
or *column* must be 0, but not both.
The *column* argument is optional and defaults to 0.
Also, the matrices must conform in the
dimension in which they are joined.
For example, the statements

a={1 2, 3 4};
b={5 6, 7 8};
c=insert(a, b, 2, 0);
d=insert(a, b, 0, 3);

produce the result
C 4 rows 2 cols (numeric)
1 2
5 6
7 8
3 4
D 2 rows 4 cols (numeric)
1 2 5 6
3 4 7 8

**C** shows the result of insertion in the
middle, while **D** shows insertion on an end.

Copyright © 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.