SAS Component Language Dictionary |
Category: | List |
Syntax | |
Details | |
Example | |
See Also |
Syntax |
n=LISTLEN(list-id ); |
contains either the length of an SCL list or status information:
>0 | |
0 | |
-1 |
is the identifier of the list whose length is being queried, or any other number.
Details |
The length of a list is the number of items in the list, excluding the contents of sublists. Because LISTLEN returns -1 if list-id is an invalid list identifier, you can use LISTLEN to determine whether a list exists. For example:
listid=getniteml(envlist('G'),'MYLIST'); invalid=(listlen(listid)=-1); if invalid then do; put 'MYLIST in the global environment has been deleted.'; stop; end;
Example |
Create the empty list LISTA, and then insert LISTA into a copy of itself, LISTB. The lengths of the two lists are then computed and are stored in the variables LEN_A and LEN_B.
lista=makelist(); listb=copylist(lista); listb=insertl(listb,lista); len_a=listlen(lista); len_b=listlen(listb); _msg_='The length of LISTA is '||len_a||' and '|| 'the length of LISTB is '||len_b;
This example shows that the length of LISTA is 0, whereas the length of LISTB is 1.
See Also |
Copyright © 2009 by SAS Institute Inc., Cary, NC, USA. All rights reserved.