Language Reference


NUM Function

NUM (matrix);

The NUM function produces a numeric representation of elements in a character matrix. If you have a character matrix for which each element is a string representation of a number, the NUM function produces a numeric matrix with dimensions that are the same as the dimensions of the argument and with elements that are the numeric representations (double-precision floating-point) of the corresponding elements of the argument.

For example, following statements display the result of converting a character matrix to a numeric matrix:

c = {"1" "2" "3"};
reset print;       /* display values and type of matrices */
m = num(c);

Figure 25.247: Numeric Matrix

m 1 row 3 cols (numeric)

1 2 3



You can also use the PUTN function in Base SAS software to apply a SAS format to each element of a numeric matrix. The resulting matrix is character-valued.

See also the description of the CHAR function , which converts numeric matrices into character matrices.