I often need to concatenate two fields, let's call them name_1 and name_2, into one field - Ful_name. I'm not entirely sure whether one or both of these fields has leading or trailing spaces.
My first attempt:
Strip(Name_1) || " " || Strip(Name_2)
works fine. I tested this code today and 7 million rows processed in 0.2 seconds.
My second attempt uses the CATX function. This takes the format:
CATX(delimiter, first_string, second_string, third_string etc)
So I used, CATX(' ', Name_1, Name_2)
CATX removes leading and trailing blanks from the specified strings and then concatenate these results using the specified delimiter - here a space character.
This version processed the 7 million rows in 0.1 seconds, a 50% improvement.
SAS built in functions will almost always work more efficiently than user designed versions, so it's worth studying the SAS functions!
There's documentation about CATX here.