Chapter Contents

Previous

Next
%LENGTH

%LENGTH



Returns the length of a string

Type: Macro function


Syntax
Details
Example
Returning String Lengths

Syntax

%LENGTH (character string | text expression)


Details

If the argument is a character string, %LENGTH returns the length of the string. If the argument is a text expression, %LENGTH returns the length of the resolved value. If the argument has a null value, %LENGTH 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 %length(&a).;
%put The length of &b is %length(&b).;
%put The length of &a &b To You is %length(&a &b to you).;

Executing these statements writes 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.


Chapter Contents

Previous

Next

Top of Page

Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.