从SAS中的文本字符串中提取6位和8位数字

时间:2016-01-20 10:39:34

标签: sql sas proc-sql

长期读者,第一次海报

我已经找到了答案,但我的技能范围内没有任何内容可以转换为解决方案。我很感激任何帮助!

我正在尝试从SAS中的文本数据集中提取数字,因此在ProcSQL或DATAstep中。

我想从自由文本字段中返回数字组。

此字段包含:

  • 一个8位数字
  • 以上和一个6位数字,有时会被各种标点符号分成2组
  • 既不

- 文本中的任何一点,无论是否有任何长度的文本。例如:

REC    NOTES

001    Collateral 83948572 (code 56/56-55) open June 2013

002    Scoobydoo 12.12.12 88888888

003    54545454 over three years

我想提取输出:

8-digit no. if present     | 6-digit no. if present

83948572                   | 565655
88888888                   | 121212
54545454                   |

任何人都可以提出我可能会看到的方向吗?

2 个答案:

答案 0 :(得分:0)

使用firebase.child("auctions/a").set(true);SUBSTRING& STUFF函数。

PATINDEX

答案 1 :(得分:0)

试试这个:

data have;
input REC $    NOTES $60.;
temp=prxchange('s/[a-z]+//i',-1,notes);
do i=1 to countw(temp);
   num=compress(scan(temp,i,' '),,'kd');
   if length(num)=8 then num8=num;
   else if length(num)=6 then num6=num;
end;
drop notes num i temp;
cards;
001    Collateral 83948572 (code 56/56-55) open June 2013
002    Scoobydoo 12.12.12 88888888
003    54545454 over three years
;
proc print ;
run;