Functions and CALL Routines |
Category: | Character |
Restriction: | I18N Level 0 |
Syntax | |
Arguments | |
Details | |
Length of Returned Variable | |
Length of Returned Variable: Special Cases | |
Comparisons | |
Examples | |
See Also |
Syntax |
CATT(item-1 <, ... item-n>) |
specifies a constant, variable, or expression, either character or numeric. If item is numeric, then its value is converted to a character string by using the BESTw. format. In this case, leading blanks are removed and SAS does not write a note to the log.
Details |
In a DATA step, if the CATT function returns a value to a variable that has not previously been assigned a length, then that variable is given a length of 200 bytes. If the concatenation operator (||) returns a value to a variable that has not previously been assigned a length, then that variable is given a length that is the sum of the lengths of the values which are being concatenated.
The CATT function returns a value to a variable, or returns a value in a temporary buffer. The value that is returned from the CATT function has the following length:
up to 32767 characters in the DATA step except in WHERE clauses
up to 65534 characters when CATT is called from the macro processor
If CATT returns a value in a temporary buffer, the length of the buffer depends on the calling environment, and the value in the buffer can be truncated after CATT finishes processing. In this case, SAS does not write a message about the truncation to the log.
If the length of the variable or the buffer is not large enough to contain the result of the concatenation, SAS does the following:
changes the result to a blank value in the DATA step, and in PROC SQL
writes a warning message to the log stating that the result was either truncated or set to a blank value, depending on the calling environment
writes a note to the log that shows the location of the function call and lists the argument that caused the truncation
The CATT function removes leading and trailing blanks from numeric arguments after it formats the numeric value with the BESTw. format.
Comparisons |
The results of the CAT, CATS, CATT, and CATX functions are usually equivalent to results that are produced by certain combinations of the concatenation operator (||) and the TRIM and LEFT functions. However, the default length for the CAT, CATS, CATT, and CATX functions is different from the length that is obtained when you use the concatenation operator. For more information, see Length of Returned Variable.
Using the CAT, CATS, CATT, and CATX functions is faster than using TRIM and LEFT, and you can use them with the OF syntax for variable lists in calling environments that support variable lists.
The following table shows equivalents of the CAT, CATS, CATT, and CATX functions. 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 CATT function concatenates strings.
data _null_; x=' The Olym'; y='pic Arts Festi'; z=' val includes works by D '; a='ale Chihuly.'; result=catt(x,y,z,a); put result $char.; run;
The following line is written to the SAS log:
----+----1----+----2----+----3----+----4----+----5----+----6----+----7 The Olympic Arts Festi val includes works by Dale Chihuly.
See Also |
|
Copyright © 2011 by SAS Institute Inc., Cary, NC, USA. All rights reserved.