REVERSE Function

Reverses a character string.

Category: Character
Restriction: I18N Level 0 functions are designed for use with Single Byte Character Sets (SBCS) only.
Tip: DBCS equivalent function is KREVERSE in SAS National Language Support (NLS): Reference Guide.

Syntax

REVERSE(argument)

Required Argument

argument

specifies a character constant, variable, or expression.

Details

In a DATA step, if the REVERSE function returns a value to a variable that has not previously been assigned a length, then that variable is given the length of the first argument.
The last character in the argument becomes the first character in the result, the next-to-last character in the argument becomes the second character in the result, and so on.
Note: Trailing blanks in the argument become leading blanks in the result.

Example

The following SAS statements produce this result.
SAS Statement
Result
----+----1
backward=reverse('xyz  ');
put backward $5.;
 
  zyx