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

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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