![]() | ![]() | ![]() | ![]() |
The results of concatenating text strings are equivalent with both methods. However, the CATS function uses less code and processes the concatenation faster than the combination method, which uses multiple calls.
The CATS function is similar to the CATX function in that both functions concatenate strings as well as remove leading and trailing blanks. However, unlike the CATX function, CATS does not insert separators into the string.
Example 1: Creating a SAS Date Constant by Using the Combination Method
The following example uses the combination method to create a SAS date constant in the format '05Jun2006'd:
data _null_; month="Jun "; day=" 05 "; year=" 2006 "; date="'"||trim(left(day))||trim(left(month)) ||trim(left(year))||"'d"; put date= ; run;
Example 2: Creating a SAS Date Constant by Using the CATS Function
The following code returns the same value (‘05Jun2006’d) as that shown in Example 1. However, the code in this example consolidates the concatenation in one call (the CATS function), which saves time both in coding and in processing:
data _null_; month="Jun "; day=" 05 "; year=" 2006 "; date=cats("'", day, month, year,"'d"); put date= ; run;
For detailed information, see "CATS Function" in SAS Language Reference: Dictionary under Base SAS in SAS OnlineDoc 9.1.3.
About the Author
This tip was suggested by Nina L. Werner. Nina is a SAS programmer with more years experience than she wants to say.
Product Family | Product | System | SAS Release | |
Reported | Fixed* | |||
SAS System | Base SAS | All | n/a |