使用SAS,我有一个包含句子的表,我正在寻找表中利用模糊匹配(complev function
)在句子中找到关键字的行。有没有办法在SAS中找到句子中的关键字字符串?我知道如何使用complev
,但我只能使用它来比较完整的字符串,而不能将字符串作为更大字符串的一部分。对于这个示例表,关键字将是'example'
,比较结果将在列Result
中。谢谢你的点子!
This is an Example sentence : 1
Here is another one : 0
Also an exmple : 1
The examples keep coming : 1
No worries : 0
发布于 2020-03-17 20:58:09
看看是否可以将其用作模板。我将Complev值与3进行比较,但您可以将其设置为任何拟合值。
data have;
input string $ 1-25;
datalines;
Example sentence
Here is another one
Also an exmple
The examples keep coming
No worries
;
data want;
set have;
result = 0;
do _N_ = 1 to countw(string);
if complev('example', scan(string, _N_)) < 3 then do;
result=1; leave;
end;
end;
run;
编辑:如果希望比较不区分大小写,请使用complev('example', scan(string, _N_), 'i')
。
https://stackoverflow.com/questions/60722415
复制相似问题