|
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
On Fri, 9 Jan 2009 11:16:48 -0800, Adriano Rodrigues <adriano@GPP.COM.BR>
wrote:
>Hi all,
>
>
>
>Having character strings, I want know how many streaks of numbers each
>string has, witch functions may I use for it?
>
>
>
>Data strings;
>
>Input string $ 60.;
>
>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;
>
>
>
>desired output:
>
>string numberstreaks
>
>AC BB 203 CC 404 2
>
>ACX 88 CC 1
>
>AC BB 20 3CC404 3
>
>AC BB 915 CC 404 2
>
>AC BB 03 CC 404 2
>
>AC BB 503 CC 404 X 55463 3
>
>BF DDFAR 0
>
>
>
>Thanks!
>
>Adriano
|