|
5#

楼主 |
发表于 2011-9-20 14:20:32
|
只看该作者
Re: 如果从一字符串中提取数字和日期?
[code:38jfoo1a]data test;
str='SPAIN, KINGDOM OF GOVERNMENT 5.75 30-JUL-2032';output;
str='ASIF III JERSEY LTD 5.75 26-SEP-2005';output;
str='A American Airlines Inc (9.9% 15-Jan-2010)';output;
str='B Amr Corp (4.25% 23-Sep-2023)';output;
str='CCC INC(15-Apr-2015)';output;
run;
data test;
set test;
put '***' str '***';
str=translate(str,' ','(',' ','%',' ',')');
Maturity=input(scan(str,-1,' '),date11.);
if anyalpha(scan(str,-2,' '))=0 then do;
Coupon=input(scan(str,-2,' '),best.);
call scan(str,-2,p,l,' ');
end;
else call scan(str,-1,p,l,' ');
Company=substr(str,1,p-1);
put company= /coupon= /maturity= date9./;
run;[/code:38jfoo1a] |
|