FIRST Method

Copies the first item in a dictionary to a specified variable and sets the iterator to the first position.

Applies to:Dictionary Object
See:For more information, see Using Dictionary Objects.

Syntax

Required Arguments

rc

specifies whether the method succeeded or failed. A return code of 0 indicates success; a nonzero value indicates failure.

object-reference

specifies the name of the object.

data-variable

specifies a variable to store a copy of the first item in the dictionary. If the data-variable specified is not the same data type as the first item in the dictionary, the data-variable is set to MISSING.

Optional Arguments

data-type

specifies a variable that stores the returned data type found as a numeric value or MISSING if there is no data.

array-indicator

specifies a variable that stores the array indicator value. If there is no data, the value is set to MISSING.

Details

The FIRST method stores a copy of the first data item in a dictionary in a specified variable and sets the dictionary iterator to the first position in the dictionary. The copy is stored in the first argument, data-variable. The argument data-variable must be the same data type as the dictionary data item or it is set to missing. Additional information about the first data item can be returned by using the optional arguments data-type and array-indicator.

Note: The data item that is returned by the FIRST method does not correspond to the first item sequentially stored in the dictionary in your program. The order of data items in a dictionary is not sequential and can change as the data items in the dictionary change.

The optional arguments use these return codes:

Data Type Return Codes

Return Code

Data Type

1

double

2

char

0

MISSING

–1

dictionary

–2

hash object

–3

hash iterator

–4

Other object

–5

ASTORE object

–6

Python object

Array Indicator Return Codes

Return Code

Description

1

The data at the specified location is an array.

0

The data at the specified location is not an array.

MISSING

There is no data at the specified location.

Example: Returning the First Item in a Dictionary Using the FIRST Method

proc fcmp;
   declare dictionary d;
   DFirst = .; DType = .;IsArr = .;
   d[1] = 25; d[2] = 'test-string'; d["key"] = 534;
   rc = d.first(DFirst, DType, IsArr);
   put DFirst= DType= IsArr=;
run;

The preceding statements produce these results:

DFirst=534 DType=1 IsArr=0
Last updated: August 19, 2026