Compress, Strip, and Trim

The compress, strip, and trim functions help us deal with blanks in strings. Based on the following example, try and figure out the differences in the Compress, Strip, and Trim functions:

Data Compare;
Length String $20.;
Format String $20.;
String = " 3 fn comparison ";
Compress="#"||Compress(String)||"#";
Trim="#"||Trim(String)||"#";
Strip="#"||Strip(String)||"#";
Run;

This will result in the following output:

We have used the concatenation (||) parameters to highlight how these three functions deal with blanks.

COMPRESS removes all blanks from the string (not just the leading and trailing). TRIM only removes the trailing blank whereas STRIP has removed the leading and trailing blanks.