SAS从字符串中删除特殊字符

SAS remove special characters from string

下午好, 我有一个包含名字和姓氏列表的数据集。无论出于何种原因,其中一些名称中都有需要删除的特殊字符。该字段采用字符格式,我尝试使用以下内容仅保留允许的字符并删除所有其他字符。但是,我的结果返回时所有名称的值为空。

我做错了什么?

Data want; 
set have;
'Last Name'n=compress(last_name,"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'- ","k");
'First Name'n=compress(first_name,"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'- ","k");
drop last_name first_name;
run;

使用示例数据集进行编辑

 Data have;
    INPUT last_name $ 1-14  first_name $;
    datalines;
    thomas*   James 
    Kory-Elk  Nick
    ^Shaffner Fun
    ;
 Run;

 Data want; 
   set have;
     Last_Name_New=compress(last_name,"abcdefghijklmnopqrstuvwxyz-","kis");
     First_Name_New=compress(first_name,"abcdefghijklmnopqrstuvwxyz-","kis");
    drop last_name first_name;
 run;
 /* 'k' keeps the characters in the list instead of removing them.
    'i'  ignores the case of the characters to be kept or removed.
    's' adds space characters (blank, horizontal tab, vertical tab, carriage return, line feed, and form feed) to the list of characters.*/