Date: Fri, 9 Jan 2009 09:05:39 -0500 Gerhard Hellriegel "SAS(r) Discussion" Gerhard Hellriegel Re: how to find streak of numbers in character string?

maybe a combination of SCAN (to seperate the parts) and VERIFY to check for numbers.

However, I do not understand the line:

AC BB 20 3CC404 3

You mean that 3CC404 is numeric? I think that this should be

AC BB 20 3CC404 1

That is the result of:

Data strings; length dummy \$60; Input string \$ 60.; cnt=0; i=1; dummy=scan(string,1," "); do while (dummy ne " "); if not verify(compress(dummy),"0123456789") then cnt+1; i+1; dummy = scan(string,i," "); end; drop dummy i;

Cards; AC BB 203 CC 404 ACX 88 CC AC BB 20 3CC404 AC BB 915 CC 404 AC BB 03 CC 404 AC BB 503 CC 404 X 55463 BF DDFAR ; run;

proc print; run;

If you really mean, that CC is also a separator, something like:

Data strings; length dummy str2 \$60; Input string \$ 60.; cnt=0; i=1; str2 = translate(upcase(string)," ","ABCDEFGHIJKLMNOPQRSTUVW"); dummy=scan(str2,1," "); do while (dummy ne " "); if not verify(compress(dummy),"0123456789") then cnt+1; i+1; dummy = scan(str2,i," "); end; drop dummy i;

Cards; AC BB 203 CC 404 ACX 88 CC AC BB 20 3CC404 AC BB 915 CC 404 AC BB 03 CC 404 AC BB 503 CC 404 X 55463 BF DDFAR ; run;

proc print; run;

might do it.

Gerhard