Sample 26168: Concatenate variables prior to SAS 9
Illustrate the TRIM function for trimming trailing blanks from character variables.
As of SAS 9, the CATT function does the concatenation and trimming of blanks. See Sample #30 for more information.
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.
Variable X has a length of 20 so when the concatenation takes place, the trailing blanks remain on the value. When the TRIM function is used, those trailing blanks are trimmed so that the X and Y variables are put together with no space between them.
data a;
length x $20;
x='tom';
y='cat';
z=trim(x)||y;
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 x y z
1 tom cat tomcat
Since character variables are padded with blanks up to the length of the variable, the TRIM function is needed to trim those blanks before concatenating to another variable.
| Type: | Sample |
| Topic: | SAS Reference ==> DATA Step SAS Reference ==> Functions ==> Character
|
| Date Modified: | 2007-11-01 16:19:01 |
| Date Created: | 2007-06-28 12:06:59 |
Operating System and Release Information
| SAS System | Base SAS | All | n/a | n/a |