Chapter Contents


Organizational Chart: _search

Organizational Chart: _search

Returns the numeric identifier of the first or successive node that contains the specified string or numeric value



CALL NOTIFY (orgchart-name, '_search', node-id, attribute-name, list-id);

Argument Type Description
N returns the numeric identifier of the node, or 0 if the value is not found. You may pass in the node identifier of a subtree to search when using the /C option in attribute-name.
C specifies a single, quoted text string containing the name of the node variable whose value you are searching for. attribute-name can include one or more of these node variables: ID, CVALUE, NODEID, NVALUE, OBS, or TEXT. Although the list can contain more than one node variable name, you can only search on one node variable at a time.

You can control the search by including one of these options anywhere in the text string:
/S (substring) if the node variable is character, allow the search value in list-id to be a substring of the actual node data.
/N (next) start the search at the node where any previous _search stopped.
/C (current) search only the current subtree beginning with the node identified by node-id.
/R (reverse) search in reverse order of the default.
N specifies the identifier of an SCL list containing the numeric or character data to search for. Each list item contains a data value and an item name that corresponds to a node variable name. The list can contain multiple items, but only the value of the item whose name is specified in attribute-name is searched for.

Note:   Any missing numeric value in the table or SCL list used as a search value will be converted to a zero (0) before the search is performed.  [cautionend]

If you need to search using the next node (/N) when the subtree restriction is active and node-id is equal to the original subtree, you must use the /C /N options together. Performing an intial search with /C and subsequent searches with just /N will not work.

The organizational chart always traverses down a node's right-most child by default. Calling the _search method for non-unique patterns starts finding matches from the right-most child subtree and continuing forward. However, when the organizational chart is rendered as a directory tree structure, this order is not appropriate as the first matches may actually exist at the bottom of the tree before progressing upwards. In such situations, it is recommended that you use the '/R' flag to force the _search method to traverse down the left-most tree at any given node.


This example searches various nodes. First, find the first node whose character value is 'MYLIB.MYCAT.MYPROG.SCL' and place that node in the viewable area:

mylist = makelist(0);
mylist = insertc(mylist,'mylib.mycat.myprog.
call notify('org1', '_search_', nodeid,
            'cvalue', mylist);
call notify('org1', '_goto_node_', nodeid);

Next, find the first node whose numeric value is 32 and go to that node:

mylist = insertn(mylist,32,1,'nvalue');
call notify('org1', '_search_', node-id,
            'nvalue', mylist);

Then, find the first node whose display text contains 'Smith' and use /N to start where the previous search left off:

mylist = insertc(mylist,'Smith',1,'text');
call notify('org1', '_search_', node-id,
            'text /s /n', mylist);
rc = dellist(mylist);

Chapter Contents



Top of Page

Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.