TRANSLATE Function


Replaces specific characters in a character expression

Category: Character

See: TRANSLATE Function in the documentation for your operating environment.

Syntax

TRANSLATE ( source,to-1,from-1 <, to-n,from-n >)

Arguments

source

  • specifies the SAS expression that contains the original character value.

to

  • specifies the characters that you want TRANSLATE to use as substitutes.

from

  • specifies the characters that you want TRANSLATE to replace.

  • Interaction: Values of to and from correspond on a character-by-character basis; TRANSLATE changes character one of from to character one of to , and so on. If to has fewer characters than from , TRANSLATE changes the extra from characters to blanks. If to has more characters than from , TRANSLATE ignores the extra to characters.

Operating Environment Information: You must have pairs of to and from arguments on some operating environments. On other operating environments, a segment of the collating sequence replaces null from arguments. See the SAS documentation for your operating environment for more information.

Details

If the TRANSLATE function returns a value to a variable that has not yet been assigned a length, by default the variable length is determined by the length of the first argument.

The maximum number of pairs of to and from arguments that TRANSLATE accepts depends on the operating environment you use to run SAS. There is no functional difference between using several pairs of short arguments, or fewer pairs of longer arguments.

Comparisons

The TRANWRD function differs from TRANSLATE in that it scans for words (or patterns of characters) and replaces those words with a second word (or pattern of characters).

Examples

SAS Statements

Results

x=translate( ' XYZW ' , ' AB ' , ' VW ' );

 

put x;

XYZB

See Also

Function:

  • 'TRANWRD Function' on page 860




SAS 9.1 Language Reference Dictionary, Volumes 1, 2 and 3
SAS 9.1 Language Reference Dictionary, Volumes 1, 2 and 3
ISBN: N/A
EAN: N/A
Year: 2004
Pages: 704

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net