The TRIM function is used to remove trailing spaces from character values. It is usually used when concatenating variables.
Both variables have a length of 10:
length var1 var2 $ 10;
input var1 $ var2 $;
Remove Trailing Spaces from Text
When concatenating variables in SAS, you might get unwanted spaces between the values being combined.
comb = var1 || var2;
There are blank spaces between the two values:
The blank spaces come from the trailing spaces from the VAR1 variable.
You can use the TRIM function to remove them:
comb = trim(var1) || var2;
The character values are concatenated with the unwanted spaces removed:
Become a Certified SAS Specialist
Get access to two SAS base certification prep courses and 150+ practice exercises