t**********r 发帖数: 182 | 1 一段descriptions中,如果有“apple ”, 或 "orange",或 "grape", 就让fruit_
dummy =1; otherwise, fruit_dummy=0。
I tried the following codes; but these codes can only identify ONE word. How
can I identify multiple similar words??? thanks.
if index(lowcase(descriptions),'apple')>0 then fruit_dummy=1;
else fruit_dummy=0; run; |
d*******o 发帖数: 493 | 2 加起来如何?
if (index(lowcase(descriptions),'apple')+index(lowcase(descriptions),'orange
'+index(lowcase(descriptions),'grape'))>0 then fruit_dummy=1;
else fruit_dummy=0; run; |
t**********r 发帖数: 182 | 3 tried. not workable, as all obs are identified. |
g*****d 发帖数: 526 | 4 我大概会这么写。
index('apple orange grape',lowercase(descriptions)) then fruit_dummy=1;
else fruit_dummy=0; |
a***e 发帖数: 102 | 5 Maybe you can try this:
if indexc(upcase(descriptions), "APPLE", "ORANGE", "GRAPE")>0 THEN fruit_
dummy=1;else fruit_dummy=0; |
y*m 发帖数: 102 | 6 this won't work as indexc searches for individual characters, not patters
【在 a***e 的大作中提到】 : Maybe you can try this: : if indexc(upcase(descriptions), "APPLE", "ORANGE", "GRAPE")>0 THEN fruit_ : dummy=1;else fruit_dummy=0;
|
a***e 发帖数: 102 | 7 yeah,I think u are right. |
R******d 发帖数: 1436 | 8 这个比较婉转,不过可以用
data _null_;
length a b $20;
gt_re = prxparse('s/apple|orange|grape//');
a="xxxxorangeeeee";
b=a;
call prxchange(gt_re, -1, b);
if length(b)
put a= b= dummy=;
run; |
t*********g 发帖数: 71 | 9 How about this?
if (index(lowcase(descriptions),'apple')
or index(lowcase(descriptions),'orange')
or index(lowcase(descriptions),'grape') )
then fruit_dummy=1;
else fruit_dummy=0; run; |