FIRST Function

Returns the first character in a character string.

Category: Character

Syntax

FIRST(string)

Required Argument

string

specifies a character string.

Details

In a DATA step, the default length of the target variable for the FIRST function is 1.
The FIRST function returns a string with a length of 1. If string has a length of 0, then the FIRST function returns a single blank.

Comparisons

The FIRST function returns the same result as CHAR(string, 1) and SUBPAD(string, 1, 1). While the results are the same, the default length of the target variable is different.

Example

The following example shows the results of using the FIRST function.
data test;
   string1="abc";
   result1=first(string1);
   string2="";
   result2=first(string2);
run;
proc print noobs data=test;
run;
Output from the FIRST Function
Output from the FIRST Function

See Also

Functions: