- 阅读权限
- 255
- 威望
- 6 级
- 论坛币
- 91928 个
- 通用积分
- 23.5045
- 学术水平
- 424 点
- 热心指数
- 505 点
- 信用等级
- 256 点
- 经验
- 112941 点
- 帖子
- 2930
- 精华
- 0
- 在线时间
- 2532 小时
- 注册时间
- 2007-4-26
- 最后登录
- 2025-6-25
已卖:401份资源
院士
还不是VIP/贵宾
- 威望
- 6 级
- 论坛币
 - 91928 个
- 通用积分
- 23.5045
- 学术水平
- 424 点
- 热心指数
- 505 点
- 信用等级
- 256 点
- 经验
- 112941 点
- 帖子
- 2930
- 精华
- 0
- 在线时间
- 2532 小时
- 注册时间
- 2007-4-26
- 最后登录
- 2025-6-25
 | 开心 2022-12-2 09:14:56 |
|---|
签到天数: 144 天 连续签到: 1 天 [LV.7]常住居民III
|
经管之家送您一份
应届毕业生专属福利!
求职就业群
感谢您参与论坛问题回答
经管之家送您两个论坛币!
+2 论坛币
全文请参见:
http://crackman.net/?p=1257
如何去发现一个包含有多个word的字符变量,是否包含某一个word,我们一般有find函数
以及index函数,这两个方法来处理
第一个:这里需要对变量进行大写化处理
proc freq data=sashelp.zipcode;
where index(upcase(statename),”ISLAND”) > 0;
tables statename;
title1 “Count for each ‘Island’ area”;
run;
第二个方法:
采用find函数(SAS9.X)支持的新函数
proc freq data=sashelp.zipcode;
where find(statename,”Island”,”i”) > 0;
tables statename;
title1 “Count for each ‘Island’ area”;
run;
Count for each ‘Island’ area 1
2011年03月05日 星期六 下午05时57分39秒
FREQ PROCEDURE
Full name of state/territory
累积 累积
STATENAME 频数 百分比 频数 百分比
———————————————————————
Northern Mariana Islands 3 2.73 3 2.73
Rhode Island 91 82.73 94 85.45
Virgin Islands 16 14.55 110 100.00
看看find函数的介绍:通过几个例子来说明一下
EX1:最简单的用法,就是用在She sells seashells? Yes, she does.寻找第一个独立的she这个单词在哪个位置,返回的是27
说明she这个word出现在上面这段字符串中第27个字符处。
data crackman;
whereisshe=find(‘She sells seashells? Yes, she does.’,'she ‘);
put whereisshe;
run;
EX2:注意这里的’I'参数是忽略要查询单词中字符的大小写差异
data crackman;
variable1=’She sells seashells? Yes, she does.’;
variable2=’she ‘;
variable3=’i';
whereisshe_i=find(variable1,variable2,variable3);
put whereisshe_i;
run;
EX3:
data crackman;
expression1=’She sells seashells? ‘||’Yes, she does.’;
expression2=kscan(‘he or she’,3)||’ ‘;
expression3=trim(‘t ‘);
whereisshe_t=find(expression1,expression2,expression3);
put whereisshe_t;
run;
这里其实对t这个参数的解释,如果有t这个参数表示的是忽略要查询和被查询字符串中的前后空格符对于查询匹配的影响,例如第一个例子里面
因为没有t参数,所以结果是27,这里结果是14,也就是在seashe…中的she进行匹配的
其他更多的情参考help文档
扫码加我 拉你入群
请注明:姓名-公司-职位
以便审核进群资格,未注明则拒绝
|
|
-
总评分: 学术水平 + 2
热心指数 + 2
信用等级 + 2
查看全部评分
|