REPEAT: Repeating a String a Given Number of Times

How to:

Given a source string and an integer number, REPEAT returns a string with the source string repeated that number of times. The string containing the repeated strings must be large enough to fit the repetitions or it will contain a truncated value.

Syntax: How to Repeat a Character String a Given Number of Times

REPEAT(source_str, number)

where:

source_str

Alphanumeric

Is the source string to be repeated. If source_str is a field, the entire field, including blanks, will be repeated.

number

Numeric

Is the number of times to repeat the source string.

Example: Repeating a String a Given Number of Times

The following request returns a string with FIRST_NAME repeated three times.

TABLE FILE EMPLOYEE
PRINT FIRST_NAME 
COMPUTE REPEAT3/A25 = REPEAT(FIRST_NAME,3);
ON TABLE SET PAGE NOLEAD
ON TABLE PCHOLD FORMAT PDF
ON TABLE SET STYLE *
GRID=OFF,$
ENDSTYLE
END

The PDF output is shown in the following image.