Published on :
ETL CREATION_INTERNE

Simplified String Concatenation

This code is also available in: Deutsch Español Français English
Awaiting validation
This script creates a temporary dataset to compare two methods of concatenating character strings containing superfluous spaces. It contrasts the classic method using a combination of TRIM, LEFT, and the concatenation operator (!!) with the modern CATX function, which automatically handles blank suppression and separator insertion.
Data Analysis

Type : CREATION_INTERNE


Data is dynamically created in the Data step (variables a and b initialized with literal strings).

1 Code Block
DATA STEP Data
Explanation :
Data step creating the 'test' table. Variable 'c' shows complex manual concatenation (trimming leading/trailing spaces then joining). Variable 'd' shows the use of CATX(' ', a, b) which performs the same operation more concisely. Results are sent to the log via PUT.
Copied!
1DATA test ;
2 a=' Phil ' ;
3 b=' Mason ' ;
4 c=trim(left(a))!!' '!!left(b) ;
5 d=catx(' ',a,b) ;
6 put c= d= ;
7RUN ;
This material is provided "as is" by We Are Cas. There are no warranties, expressed or implied, as to merchantability or fitness for a particular purpose regarding the materials or code contained herein. We Are Cas is not responsible for errors in this material as it now exists or will exist, nor does We Are Cas provide technical support for it.