Syntax Supported by the IML Procedure and the iml Action

LISTADDITEM Call

CALL LISTADDITEM (list, v, <, flag> ) ;

This subroutine is supported by the IML procedure and the iml action.

The ListAddItem subroutine adds a new item to end of a list. The length of the list increases by one. For examples and a general discussion of using lists, see Chapter 9, Lists and Data Structures (SAS/IML User's Guide).

The subroutine takes the following arguments:

list

specifies an existing list.

v

specifies a SAS/IML variable or literal. It can be a matrix, table, list, or any other valid SAS/IML type, including an empty matrix. The value of v will become a new list element.

flag

controls what happens to v. Valid values are:

'c'

copies the data in v into the list. The v symbol is unchanged by the call. This is the default behavior.

'm'

moves the data in v into the list. The v symbol is freed after the call.

The following statements create an empty list and then add two items:

L = ListCreate();              /* create empty list */
v1 = 1:3;
call ListAddItem(L, v1);       /* v1 is unchanged */
v2 = {"A", "Z"};
call ListAddItem(L, v2, 'm');  /* v2 is freed */

When you need to combine two lists, you can use the list concatenation operator (||). For example, if S and T are two lists, then L = S || T is the list that contains all items of S followed by all items of T.

Last updated: March 08, 2024