SAS Component Language Dictionary |
Category: | List |
Syntax | |
Details | |
Examples | |
Example 1: Using the SEARCHC Function | |
Example 2: Using the SEARCHL Function | |
Example 3: Using the SEARCHN Function | |
Example 4: Using the SEARCHO Function | |
See Also |
Syntax |
index=SEARCHC(list-id, cval<, occurrence<, start-index<, ignore-case<, prefix>>>>); |
index=SEARCHL(list-id, sublist-id<, occurrence<, start-index>>); |
index=SEARCHN(list-id, nval<, occurrence<, start-index >>); |
index=SEARCHO(list-id, object-id<, occurrence<, start-index>>); |
contains the index from the SCL list of the item that has the specified character value, or 0 if the value was not found.
is the identifier of the list to search. An invalid list-id produces an error condition.
is the character value for SEARCHC to search for. Cval is compared only to the character values in the list.
contains the identifier of the sublist for SEARCHL to search for. Sublist-id is compared only to the list identifiers in the list.
is the numeric value for SEARCHN to search for. Nval is compared only to numeric values in the list.
contains the identifier of the object for SEARCHO to search for. Object-id is compared only to the object identifiers in the list.
is the occurrence of the value to search for. The default, 1, indicates the first occurrence of the item.
is the position in the list at which to start the search for the item. By default, start-index is 1 (the first item). If start-index is positive, then the search begins at position start-index items from the beginning of the list. If start-index is negative, then the search begins at the item specified by ABS(start-index) items from the end of the list. An error condition results if the absolute value of start-index is zero or if it is greater than the number of items in the list.
specifies how SEARCHC should compare string values:
'Y' | |
'N' |
does a case-sensitive comparison of the character strings. (This is the default.) |
specifies whether the value should be treated as a prefix:
Details |
SEARCHC, SEARCHL, SEARCHN, and SEARCHO do not search for a value in any sublists of the list identified by list-id.
If occurrence and start-index are both positive or both negative, then the search proceeds forward from the start-index item. For forward searches, the search continues only to the end of the list and does not wrap back to the front of the list. If either occurrence or start-index is negative, then the search proceeds from the last item toward the beginning of the list. For backward searches, the search continues only to the beginning of the list and does not wrap back to the end of the list.
To search for an item by name rather than by value, use NAMEDITEM.
Examples |
Find the position of the next-to-last occurrence of a string that begins with SAS, ignoring case:
last2=searchc(mylistid, 'sas', 2, -1, 'Y', 'Y');
Search the list identified by MYLISTID for the third occurrence of the identifier for the sublist item identified by the value of NAMELISTID:
third=searchl(mylistid, namelistid, 3);
Search for the third occurrence of the number 46 in the list identified by MYLISTID:
third=searchn(mylistid, 46, 3);
Search the list identified by MYLISTID for the third occurrence of the identifier for the object BUTTON:
third=searcho(mylistid,objectid,3);
See Also |
Copyright © 2009 by SAS Institute Inc., Cary, NC, USA. All rights reserved.