Previous Page | Next Page

SAS Component Language Dictionary

HASATTR



Reports whether an SCL list or a list item has a specified attribute
Category: List

Syntax
Details
Examples
Example 1: Clearing a List That Has a Particular Attribute
Example 2: Determining Whether a List Item Has a Particular Attribute
See Also

Syntax

rc=HASATTR(list-id,attribute<,index>);

rc

contains the return code for the operation:

1

The list or item has the specified attribute.

0

The list or item does not have the specified attribute.

Type: Numeric

list-id

is the identifier of the list that HASATTR searches. An invalid list-id produces an error condition.

Type: Numeric or List

attribute

is an attribute for a list or list item, as described in SETLATTR. In addition, you can test for the following special attributes:

'G'

returns 1 if the list is a global list.

'L'

returns 1 if the list is a local list.

'C'

returns 1 if the list identifier is also a class identifier.

'O'

returns 1 if the list identifier is also an object identifier.

Type: Character

index

is the position of the item in the list. The position can be specified as a positive or negative number. By default, index is 1 (the first item). If index is omitted, HASATTR checks to see if the specified list has the named attribute. If index is specified, HASATTR checks to see if the specified item has the named attribute. If index is a positive number, then the item is at position index from the beginning of the list. If index is a negative number, then the item is at position ABS(index) from the end of the list. An error condition results if the absolute value for index is zero or if it is greater than the number of items in the list.

Type: Numeric


Details

If no value is specified for index, HASATTR queries the attribute of the list. If a nonzero value is specified for index, HASATTR queries the attribute of an item in the list.

For a list of attributes for lists and list items, see SETLATTR.


Examples


Example 1: Clearing a List That Has a Particular Attribute

Clear the list identified by MYLIST only if it has the UPDATE attribute:

if hasattr(mylist,'UPDATE') then rc=clearlist
                                     (mylist);


Example 2: Determining Whether a List Item Has a Particular Attribute

Determine whether the third item in a list has the FIXEDTYPE attribute:

isfixed=hasattr(mylist,'FIXEDTYPE',3);


See Also

GETLATTR

SETLATTR

Previous Page | Next Page | Top of Page