SQUEEZ: Reducing Multiple Spaces to a Single Space

How to:

Available Languages: reporting, Maintain

The SQUEEZ function reduces multiple contiguous spaces within a character string to a single space. The resulting character string has the same length as the original string but is padded on the right with spaces.

Syntax: How to Reduce Multiple Spaces to a Single Space

SQUEEZ(length, source_string, output)

where:

length

Integer

Is the number of characters in source_string and output, or a field that contains the length.

source_string

Alphanumeric

Is the character string to squeeze enclosed in single quotation marks, or the field that contains the character string.

output

Alphanumeric

Is the field that contains the result, or the format of the output value enclosed in single quotation marks.

Example: Reducing Multiple Spaces to a Single Space

SQUEEZ reduces multiple spaces in the NAME field to a single blank and stores the result in a field with the format A30:

DEFINE FILE EMPLOYEE
NAME/A30 = FIRST_NAME | LAST_NAME;
END
TABLE FILE EMPLOYEE
PRINT NAME AND COMPUTE
SQNAME/A30 = SQUEEZ(30, NAME, 'A30');
WHERE DEPARTMENT EQ 'MIS';
END

The output is:

NAME                      SQNAME
----                      ------
MARY       SMITH          MARY SMITH
DIANE      JONES          DIANE JONES
JOHN       MCCOY          JOHN MCCOY
ROSEMARIE  BLACKWOOD      ROSEMARIE BLACKWOOD
MARY       GREENSPAN      MARY GREENSPAN
BARBARA    CROSS          BARBARA CROSS