楼主: fyp198744
4432 8

[问答] sas当中有没有什么函数能只保留英文二剔除中文的? [推广有奖]

  • 0关注
  • 1粉丝

讲师

2%

还不是VIP/贵宾

-

威望
0
论坛币
135 个
通用积分
0
学术水平
0 点
热心指数
0 点
信用等级
0 点
经验
5181 点
帖子
257
精华
0
在线时间
258 小时
注册时间
2016-5-23
最后登录
2019-9-30

楼主
fyp198744 发表于 2016-11-10 10:29:50 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
数据集中有些变量如“itt population 意向人群”“per protocol population 符合方案人群”长度也不固定,空格也不统一!然后就想去掉中文,只保留英文!
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

关键词:有没有 Population Protocol ulation ATION 英文 中文

沙发
prince315 在职认证  发表于 2016-11-10 11:03:41
data test;
input var  $50.;
var2 = compress(var,'abcdefghijklmnopqrstuvwxyz','ki');
cards;
itt population 意向人群
per protocol population 符合方案人群
;
run;
此法即保留了A-Za-z这类英文部分

藤椅
zhangzachary 发表于 2016-11-10 11:22:34
  1. data test;
  2. x = "abc 中文 def 测试 gg";
  3. y = compress(x,,'kfs');
  4. run;
复制代码

板凳
fyp198744 发表于 2016-11-10 13:58:00
zhangzachary 发表于 2016-11-10 11:22
kfs代表什么意思?

报纸
fyp198744 发表于 2016-11-10 13:58:21
prince315 发表于 2016-11-10 11:03
data test;
input var  $50.;
var2 = compress(var,'abcdefghijklmnopqrstuvwxyz','ki');
ki代表什么意思?

地板
lovexialulu 发表于 2016-11-10 23:57:06 来自手机
pexchange 保留\\w 其他全替换为空

7
sonypam 在职认证  发表于 2016-11-11 04:04:09
fyp198744 发表于 2016-11-10 13:58
kfs代表什么意思?
Hi, Please see the link below:
http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000212246.htm
k means Keep
f means underscore character and English letters
s means space characters (blank, horizontal tab, vertical tab, carriage return, line feed, and form feed) to the list of characters

so, kfs means only keeps underscore character and English letters and space characters.

Hope it helps,
Yang

8
fyp198744 发表于 2016-11-11 09:48:54
lovexialulu 发表于 2016-11-10 23:57
pexchange 保留\\w 其他全替换为空
什么意思?也是compress这个函数实现吗?compress(var,pexchange )这样吗?

9
lovexialulu 发表于 2016-11-11 11:15:06
fyp198744 发表于 2016-11-11 09:48
什么意思?也是compress这个函数实现吗?compress(var,pexchange )这样吗?
var=prxchange("s/([\w\s]+)(.+)/\1/",-1,var);

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2026-1-17 14:47