COMPRESS function
Returns a character string with specified characters removed from the original string.
COMPRESS(<source><, chars><, modifiers>)
chars
specifies a character constant, variable, or expression that initializes a list of characters.
By default, the characters in this list are removed from the source argument. If you specify the K modifier in the third argument, then only the characters in this list are kept in the result.
a or A
adds alphabetic characters to the list of characters.
data test; string="ABC abcdef($1234)"; noblanks=compress(string); /*去除字符串中的空格*/ nonum=compress(string,,'d'); /*去除字符串中的数字*/ nonumblank=compress(string,,'ds');/*去除字符串中的数字以及空格*/ nochar=compress(string,,'a'); /*去除字符串中所有字母*/ noabc1=compress(string,'ABC'); /*去除ABC三个大写字母*/ noabc2=compress(string,'abc','i'); /*此处加了条件i,忽略大小写,不论大小写,都将abc去除*/ nosign=compress(string,,'p'); /*去除字符串中的符号*/ nosignnum=compress(string,,'pd'); /*去除符号以及数字*/ retaina=compress(string,'a','ki'); /*不论大小写,将字符串中a字母保留下来,其他全都删掉*/ retaina=compress(string,'a','kd'); /*将字符串中数字保留下来*/
LBL=compress(string,'2040a0'x); /*去除特殊空格*/
run;
本文来自博客园,作者:Iving,转载请注明原文链接:https://www.cnblogs.com/SAS-T/p/16441947.html