Sample 24589: Concatenation functions in SAS 9.0 and above
Illustrate the new CAT functions for joining text strings.
Note:
CAT - concatenates character strings without removing leading or
trailing blanks
CATS - concatenates character strings and removes leading
and trailing blanks
CATT - concatenates character strings and removes trailing blanks
CATX - concatenates character strings, removes leading and
trailing blanks, and inserts separators
In previous versions of SAS you would have to use a combination of the LEFT, and/or the TRIM functions along with the double concatenation bars (||).
If you wanted a separator, you would have to include that inside quotes.
These sample files and code examples are provided by SAS Institute
Inc. "as is" without warranty of any kind, either express or implied, including
but not limited to the implied warranties of merchantability and fitness for a
particular purpose. Recipients acknowledge and agree that SAS Institute shall
not be liable for any damages whatsoever arising out of their use of this material.
In addition, SAS Institute will provide no support for the materials contained herein.
data test;
input (x1-x4) ($);
x5=' 5';
length new1 $40 new2-new4 $10 ;
new1=cat(of x1-x5);
new2=cats(of x1-x5);
new3=catt(x1,x2,x3,x4,x5);
new4=catx(',', of x1-x5);
keep new:;
datalines;
1 2 3 4
5 6 . 8
;
proc print;
run;
These sample files and code examples are provided by SAS Institute
Inc. "as is" without warranty of any kind, either express or implied, including
but not limited to the implied warranties of merchantability and fitness for a
particular purpose. Recipients acknowledge and agree that SAS Institute shall
not be liable for any damages whatsoever arising out of their use of this material.
In addition, SAS Institute will provide no support for the materials contained herein.
Obs new1 new2 new3 new4
1 1 2 3 4 5 12345 1234 5 1,2,3,4,5
2 5 6 8 5 5685 568 5 5,6,8,5
Illustrate the new CAT functions for joining text strings.
| Type: | Sample |
| Topic: | SAS Reference ==> DATA Step SAS Reference ==> Functions ==> Character
|
| Date Modified: | 2009-03-19 15:32:19 |
| Date Created: | 2004-09-30 14:08:56 |
Operating System and Release Information
| SAS System | Base SAS | Tru64 UNIX | 9 TS M0 | n/a |
| OpenVMS Alpha | 9 TS M0 | n/a |
| HP-UX IPF | 9 TS M0 | n/a |
| Linux | 9 TS M0 | n/a |
| 64-bit Enabled Solaris | 9 TS M0 | n/a |
| 64-bit Enabled HP-UX | 9 TS M0 | n/a |
| 64-bit Enabled AIX | 9 TS M0 | n/a |
| Microsoft® Windows® for 64-Bit Itanium-based Systems | 9 TS M0 | n/a |
| z/OS | 9 TS M0 | n/a |