The VALSET subroutine performs indirect assignment. The subroutine takes the name of a matrix and assigns a value to that matrix. Calling the VALSET subroutine is useful for assigning values to a matrix whose name is not known until run time.
The C programming language has the concept of a “pointer,” which enables you to assign values to preallocated memory. The VALSET subroutine is similar. The matrix argument contains the name of the matrix to which the value is to be assigned.
The arguments to the VALSET subroutine are as follows:
is a character matrix or literal that specifies the name of a matrix.
is a value to which the matrix is set.
For example, the following statements assign the string “A” to the value of the matrix B
. The VALSET subroutine assigns a vector to the matrix A
.
B = "A"; call valset(B, 1:5); print A;
The following statement redefines the contents of B
; it does not change the value of A
.
b = 99;
See also the VALUE function, which retrieves the value that is contained in a matrix.