Functions and CALL Routines |
Category: | Character |
Syntax | |
Arguments | |
Details | |
Comparisons | |
Examples | |
See Also |
Syntax |
CALL CATX(delimiter, result<, item-1 , ... item-n>); |
specifies a character string that is used as a delimiter between concatenated strings.
specifies a character variable.
Restriction: | The CALL CATX routine accepts only a character variable as a valid argument for result. Do not use a constant or a SAS expression because CALL CATX is unable to update these arguments. |
specifies a constant, variable, or expression, either character or numeric. If item is numeric, then its value is converted to a character string using the BESTw. format. In this case, SAS does not write a note to the log.
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 does the following:
writes a warning message to the log stating that the result was truncated
writes a note to the log that shows the location of the function call and lists the argument that caused the truncation, except in SQL or in a WHERE clause
sets _ERROR_ to 1 in the DATA step, except in a WHERE clause
The CALL CATX routine removes leading and trailing blanks from numeric arguments after formatting the numeric value with the BESTw. 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 delimiter, such as a blank or comma.
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. '; call 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 |
|
Copyright © 2011 by SAS Institute Inc., Cary, NC, USA. All rights reserved.