Previous Page | Next Page

Macro Functions for NLS

%KLENGTH Macro Function



Returns the length of a string.
Category: DBCS
Type: NLS macro function

Syntax
Details
Example
Returning String Lengths

Syntax

%KLENGTH (character string | text expression)


Details

If the argument is a character string, %KLENGTH returns the length of the string. If the argument is a text expression, %KLENGTH returns the length of the resolved value. If the argument has a null value, %KLENGTH returns 0.


Example


Example 1: Returning String Lengths

The following statements find the lengths of character strings and text expressions:

%let a=Happy;
%let b=Birthday;

%put The length of &a is %klength(&a).;
%put The length of &b is %klength(&b).;
%put The length of &a &b To You is %klength(&a &b to you).;

When these statements execute, the following is written to the SAS log:

The length of Happy is 5.
The length of Birthday is 8.
The length of Happy Birthday To You is 21.

Previous Page | Next Page | Top of Page