SAS中的正则表达式读取:
是否发生器械缺陷(If any DD exist)(code)中每一个括号中的内容。用prxposn只能读取一个括号中的内容,用prxnext可以循环读取括号中的内容。
data a;
input var& $ 50.;
cards;
是否发生器械缺陷(If any DD exist)(code)
;
run;
data b;
set a;
re=prxparse("/\((.*?)\)/");
_start = 1;
_stop = length(var);
call prxnext(re, _start, _stop, var, _pos, _len);
/* _pos, _len是查找过程中SAS生成的值并保存在这两个变量中*/
if _pos<=0 then output;
else do while (_pos > 0);
found = substr(var, _pos, _len);
put found= _pos= _len=;
output;
call prxnext(re, _start, _stop, var, _pos, _len);
end;
run;
本文介绍如何使用SAS的正则表达式功能从字符串中读取括号内的内容,通过prxparse, prxnext等函数实现循环读取,适用于数据处理和文本分析场景。
23

被折叠的 条评论
为什么被折叠?



