Previous Page | Next Page

Functions and CALL Routines

FIRST Function



Returns the first character in a character string.
Category: Character

Syntax
Arguments
Details
Comparisons
Examples
See Also

Syntax

FIRST(string)


Arguments

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.


Examples

The following example shows the results of using the FIRST function.

options pageno=1 ps=64 ls=80 nodate;

data test;
   string1="abc";
   result1=first(string1);

   string2="";
   result2=first(string2);
run;

proc print noobs data=test;
run;

Output from the FIRST Function

                                 The SAS System                                1

                    string1    result1    string2    result2

                      abc         a                         

See Also

Functions:

CHAR Function

Previous Page | Next Page | Top of Page