Previous Page | Next Page

Functions and CALL Routines

COMPBL Function



Removes multiple blanks from a character string.
Category: Character
Restriction: I18N Level 0

Syntax
Arguments
Details
Length of Returned Variable
The Basics
Comparisons
Examples
See Also

Syntax

COMPBL(source)


Arguments

source

specifies a character constant, variable, or expression to compress.


Details


Length of Returned Variable

In a DATA step, if the COMPBL function returns a value to a variable that has not previously been assigned a length, then the length of that variable defaults to the length of the first argument.


The Basics

The COMPBL function removes multiple blanks in a character string by translating each occurrence of two or more consecutive blanks into a single blank.


Comparisons

The COMPRESS function removes every occurrence of the specific character from a string. If you specify a blank as the character to remove from the source string, the COMPRESS function removes all blanks from the source string, while the COMPBL function compresses multiple blanks to a single blank and has no effect on a single blank.


Examples

The following SAS statements produce these results.

SAS Statements Results

----+----1----+----2--
string='Hey
 Diddle  Diddle';
string=compbl(string);
put string;
Hey Diddle Diddle
string='125    E Main St';
length address $10;
address=compbl(string);
put address;
125 E Main


See Also

Function:

COMPRESS Function

Previous Page | Next Page | Top of Page