Functions and CALL Routines

CALL CATX Routine



Concatenates character strings, removes leading and trailing blanks, and inserts separators
Category: Character

Syntax
Arguments
Details
Comparisons
Examples
See Also

Syntax

CALL CATX(separator, result<, string-1 , ...>string-n);

Arguments

separator

specifies a character string that is used as a separator between concatenated strings.

result

specifies a SAS variable.

string

specifies a SAS character string.


Details

The CALL CATX routine returns the result in the second argument,result. The routine appends the values of the arguments that follow to result. If the length of result is not large enough to contain the entire result, SAS

The CALL CATX routine removes leading and trailing blanks from numeric arguments after formatting the numeric value with the BEST. format.


Comparisons

The results of the CALL CATS, CALL CATT, and CALL CATX routines are usually equivalent to statements that use the concatenation operator (||) and the TRIM and LEFT functions. However, using the CALL CATS, CALL CATT, and CALL CATX routines is faster than using TRIM and LEFT.

The following table shows statements that are equivalent to CALL CATS, CALL CATT, and CALL CATX. The variables X1 through X4 specify character variables, and SP specifies a separator, such as a blank or comma.

CALL Routine Equivalent Statement
CALL CATS(res, OF X1-X4);
res=TRIM(LEFT(X1))||TRIM(LEFT(X2))||TRIM(LEFT(X3))||
TRIM(LEFT(X4));
CALL CATT(OF X1-X4);
X1=TRIM(X1)||TRIM(X2)||TRIM(X3)||TRIM(X4);
CALL CATX(SP, OF X1-X4); *
X1=TRIM(LEFT(X1))||SP||TRIM(LEFT(X2))||SP||
TRIM(LEFT(X3))||SP||TRIM(LEFT(X4));
* If any of the arguments is blank, the results that are produced by CALL CATX differ slightly from the results that are produced by the concatenated code. In this case, CALL CATX omits the corresponding separator. For example, CALL CATX("+","X"," ", "Z"," "); produces X+Z .


Examples

The following example shows how the CALL CATX routine concatenates strings.

data _null_;
   length answer $ 50;
   separator='%%$%%';
   x='Athens is t  '; 
   y='he Olym     ';
   z='  pic site for 2004.  ';
   answer=catx(separator,answer,x,y,z);
   put answer; 
run;

The following line is written to the SAS log:

----+----1----+----2----+----3----+----4----+----5
Athens is t%%$%%he Olym%%$%%pic site for 2004.


See Also

Functions and CALL Routines:

CAT Function

CATS Function

CATT Function

CATX Function

CALL CATS Routine

CALL CATT Routine

space
Previous Page | Next Page | Top of Page