![]() |
|
SAS Tip
of the Month In their basic form, the COMPRESS and COMPBL functions manipulate the blanks or spaces in a text string. The COMPBL function will remove multiple blanks in a string and replace them with a single blank it will also remove trailing and leading blanks from a string. The COMPRESS function will remove all blank spaces from a string, including the leading and trailing blanks. The COMPRESS function was enhances a few years ago to include characters that a used specified it was no longer restricted to blanks. Refer to the following examples of the functions use: 297 data _null_; 298 TextStr='1049 Park Avenue, New York, NY'; 299 TextCOMPBL = compbl(TextStr); 300 TextCOMPRESS = compress(TextStr); 301 TextCOMPRESS_withoutNumbers = compress(TextStr,'0123456789'); 302 put TextStr= / 303 TextCOMPBL = / 304 TextCOMPRESS = / 305 TextCOMPRESS_withoutNumbers =; 306 run; TextStr=1049 Park Avenue, New York, NY TextCOMPBL=1049 Park Avenue, New York, NY TextCOMPRESS=1049ParkAvenue,NewYork,NY TextCOMPRESS_withoutNumbers=Park Avenue, New York, NY |
|
| ________________________________ Updated August 1, 2003 |
|