Data F;
input No String $;
cards;
1 AAaaa
2 BBbbB
3 CCccC
4 AAbbCC
5 AAbC
6 DDdDD
7 D
8 Dd
;
run;
Data G;
input KeyWrd $;
cards;
aa
abc
bcd
;
run;作者: shiyiming 时间: 2010-3-25 08:56 标题: Re: 求教:如何用sql做动态模糊查询? 一定要求是SQL吗?用宏可以不?小宏一个,仅供参考。
[code:gwd2kaer]%macro indexkw(input=,std=,output=);
data _NULL_;
set &std end=eof;
call symput('KW'||trim(left(put(_N_,best.))),trim(left(KeyWrd)));
call symput('KWS'||trim(left(put(_N_,best.))),trim(left(put(_N_,best.))));
if eof then call symput('KWNO',trim(left(put(_N_,best.))));
run;
data &output;
set &input;
%do i=1 %to &KWNO;
if index(lowcase(String),lowcase("&&KW&i")) gt 0 then KWSEQ&i=input("&&KWS&i",best.);
%end;
run;
%mend indexkw;