Chapter Contents |
Previous |
Next |
SEARCHC, SEARCHL, SEARCHN, and SEARCHO |
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<,start-index <,occurrence<,ignore-case<,prefix>>>>); |
index=SEARCHL(list-id,sublist-id<,occurrence <,start-index>>); |
index=SEARCHNlist-id,nval(<,occurrence <,start-index>>); |
index=SEARCHO(list-id,object-id<,occurrence <,start-index>>); |
Type: Numeric
Type: Numeric or List
Type: Character
Type: Numeric
Type: Numeric
Type: Numeric or Object
Type: Numeric
Type: Numeric
'Y' |
ignores the case of the character strings. |
'N' |
does a case-sensitive comparison of the character strings. (This is the default.) |
Type: Character
'Y' |
does a prefix comparison and searches for any items that have cval as a prefix. SEARCHC compares only the first m characters, where m is the length of cval. |
'N' |
does not do a prefix search but compares all characters to cval. (This is the default.) |
Type: Character
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 |
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.