SAS/IML General Matrix Manipulation Functions and CALL Subroutines

The following general matrix manipulation functions and CALL subroutines enable you to retrieve matrix characteristics, reshape matrices, and sort matrix elements:

Matrix Inquiry Functions

Function Purpose
ALL checks for all nonzero elements
ANY checks for any nonzero elements
COUNTMISS returns the number of missing values
COUNTN returns the number of nonmissing values
COUNTUNIQUE returns the number of unique values
CHOOSE conditionally chooses and changes elements
LOC finds indices for the nonzero elements of a matrix
NCOL finds the number of columns of a matrix
NLENG finds the size of an element
NROW finds the number of rows of a matrix
TYPE determines the type of a matrix

Matrix Reshaping Functions

Function Purpose
BLOCK forms block-diagonal matrices
BTRAN computes a block transpose
DIAG creates a diagonal matrix
DO produces an arithmetic series
FULL converts a matrix stored in a sparse format into a full (dense) matrix
I creates an identity matrix
INSERT inserts one matrix inside another
J creates a matrix of identical values
REMOVE discards elements from a matrix
REPEAT creates a new matrix of repeated values
SHAPE reshapes and repeats values
SPARSE converts a matrix that contains many zeros into a matrix stored in a sparse format
SQRSYM converts a symmetric matrix to a square matrix
SYMSQR converts a square matrix to a symmetric matrix
T transposes a matrix
VECDIAG creates a vector from a diagonal

Matrix Sorting and BY-Group Processing CALL Subroutines

CALL Subroutine Purpose
SORT sorts a matrix by specified columns
SORTNDX creates a sorted index for a matrix
UNIQUEBY finds locations of unique BY groups in a sorted or indexed matrix