![]() Chapter Contents |
![]() Previous |
![]() Next |
| LOCATEC and LOCATEN |
| Category: | SAS Table |
| Syntax | |
| Details | |
| Examples | |
| Example 1: Using the LOCATEC Function | |
| Example 2: Using the LOCATEN Function | |
| See Also | |
Syntax |
| rc=LOCATEC(table-id,col-num,cval<,sort<,direction>>); |
| rc=LOCATEN(table-id, col-num,nval <,sort<,direction>>); |
| >0 | the number of rows read before a match is found |
| 0 | no row with a matching value was found |
'A' |
The table is sorted in ascending order. |
'D' |
The table is sorted in descending order. |
'U' |
The table is not sorted. (This is the default.) |
'A' |
searches all rows, starting with the first row. (This is the default.) |
'B' |
searches from the previous row backward. |
'F' |
searches from the next row forward. |
| Details |
| Examples |
customer='SMITH';
rc=locatec(tableid,varnum(tableid,'name'),customer,'a');
if (rc=0) then _msg_=
'There is no customer named '||customer||'.';
else do;
...more SCL statements...
end;
return;
houseid=open('sasuser.houses');
price=94000;
rc=locaten(houseid,varnum(houseid,'price'),price);
if (rc=0) then
_msg_='No house is priced at '||
putn(price,'dollar9.2')||'.';
else do;
rows=curobs(houseid);
_msg_=
'The specified price was found in row '||rows;
end;
return;
| See Also |
![]() Chapter Contents |
![]() Previous |
![]() Next |
![]() Top of Page |
Copyright © 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.