|
I would like to give it a try, see the code following:
DATA _NULL_;
LENGTH A B $ 200;
A='This string contains phone number like 973 123 4567, and a model number,
like Pentium III/450';
b=a;
put 'a= ' a;
a=translate(a,'~','1','~','2','~','3','~','4','~','5','~','6','~','7','~','8
','~','9','~','0');
put 'a= ' a;
pos=index(a,'~~~ ~~~ ~~~~');
substr(a,pos,12)='';
put 'a= ' a;
len=length(b);
do i=1 to len;
if substr(a,i,1) ne substr(b,i,1) and substr(a,i,1) ne ' ' then
substr(a,i,1)=substr(b,i,1);
end;
put 'a= ' a;
run;
----- log file ---
a= This string contains phone number like 973 123 4567, and a model number,
like Pentium III/450
a= This string contains phone number like ~~~ ~~~ ~~~~, and a model number,
like Pentium III/~~~
a= This string contains phone number like , and a model number,
like Pentium III/~~~
a= This string contains phone number like , and a model number,
like Pentium III/450
In case your string may already contains '~', you can replace it with
something like 'FA'x.
Hope this helps
Ya Huang
-----Original Message-----
From: Bill Kossack [mailto:kossack@NETCOM11.NETCOM.COM]
Sent: Tuesday, October 12, 1999 5:10 PM
To: SAS-L@LISTSERV.UGA.EDU
Subject: Re: Filtering out a phone number
The rest of the string can contain numbers such as equipment model
numbers that are of interest.
Richard Read Allen <rrallen@ibm.net> wrote:
: Is it possible for the useful consistent information to contain the digits
: 0-9? If not, then use compress(x,'0123456789'). If it can contain digits,
it's
: a more difficult problem.
--
William S. Kossack
Westminster, Colorado
kossack@netcom.com
[text/html]
|