BookmarkSubscribeRSS Feed
deleted_user
Not applicable
1.What is difference between trim & concat functions? Can any one give definition and example for the same?
4 REPLIES 4
deleted_user
Not applicable
I would recommend you read the documentation
JasonDiVirgilio
Quartz | Level 8
I second Chuck's recommendation, you'll usually get your answer much faster.

Trim = remove blanks from a character string;
concat = append one string to another.
deleted_user
Not applicable
TRIM removes trailing spaces etc, so if VAR1= '1234 ', you can create a new variable in the data step VAR2= TRIM(VAR1) will take out the space after 1234.

CONCAT Function

performs elementwise string concatenation

CONCAT( argument1, argument2, argument15>)
where arguments are character matrices or quoted literals.

The CONCAT function produces a character matrix containing elements that are the concatenations of corresponding element strings from each argument. The CONCAT function accepts up to 15 arguments, where each argument is a character matrix or a scalar. All nonscalar arguments must conform. Any scalar arguments are used repeatedly to concatenate to all elements of the other arguments. The element length of the result equals the sum of the element lengths of the arguments. Trailing blanks of one matrix argument appear before elements of the next matrix argument in the result matrix.
deleted_user
Not applicable
concatenate:
concatenation...means joining....concatenation operator( !! or || ) joins character strings..

eg:varname=stringA !! stringB;

TRIM:
it removes trailing blanks from the given argument.it does nt remove leading blanks .to remove leading blanks use combination of TRIM and LEFT.combination of both removes leading and trailing blanks.

eg:varname=TRIM(arg1) !! arg2;


****concatenation operator does not remove trailing blanks

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1219 views
  • 0 likes
  • 2 in conversation