DATA Step, Macro, Functions and more

BASE-SAS

Reply
N/A
Posts: 0

BASE-SAS

1.What is difference between trim & concat functions? Can any one give definition and example for the same?
N/A
Posts: 0

Re: BASE-SAS

Posted in reply to deleted_user
I would recommend you read the documentation
Contributor
Posts: 46

Re: BASE-SAS

Posted in reply to deleted_user
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.
N/A
Posts: 0

Re: BASE-SAS

Posted in reply to deleted_user
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.
N/A
Posts: 0

Re: BASE-SAS

Posted in reply to deleted_user
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
Ask a Question
Discussion stats
  • 4 replies
  • 123 views
  • 0 likes
  • 2 in conversation