Return to Archive

SAS Tip of the Month
January 2008

When looking at a SAS program you are likely to see something like the following when dealing with text strings:


What this did was left align the text in the variable original_string and then remove any blanks after the last character.

In SAS 9 a new function was introduced called STRIP that does the same task but with one function so the original code above can instead be written as:


If you are still using an older version of SAS you could do the same thing with a macro, using the following code:

    %MACRO STRIP(intxt); /*INTXT=text variable*/

You may wonder why there is no ';' at the end of the code inside the macro definition? This allows for the macro to be called inside the code multiple times, as the following example demonstrates:

Updated January 16, 2008