Hi Brian,
Replace the following command:
COMPUTE #c=RANGE(SUBSTR(qq342,cnt,1),'0','9').
with:
COMPUTE #c=ANY(SUBSTR(qq342,cnt,1),'0','1','2','3','4','5','6','7','8','9','.').
Cheers,
Jason
On 2/22/07, Brian Moore <
[hidden email]> wrote:
> Hi all-
>
> Raynald has provided (on his website) a routine to extract numbers from
> strings.
>
> COMPUTE #nb=0.
> LOOP cnt=1 TO LENGTH(RTRIM(qq342)).
> COMPUTE #c=RANGE(SUBSTR(qq342,cnt,1),'0','9').
> IF #c=1 #nb=#nb*10+NUMBER(SUBSTR(qq342,cnt,1),F1).
> END LOOP.
> COMPUTE QQ342_n=#nb.
> EXE.
>
> I'm wondering how it might be modified to also include the decimal point.
> Such that strings containing:
> 3.49
> 34.9
> 349
>
> would hold their relative values in the QQ342_n variable.
>
> Thanks,
> Brian
>