[prev in list] [next in list] [prev in thread] [next in thread]
List: sas-l
Subject: Re: converting string (spaces) to numeric
From: Peter Crawford <Peter () CRAWFORDSOFTWARE ! DEMON ! CO ! UK>
Date: 2003-08-30 10:22:05
[Download RAW message or body]
On the subject of tolerating dot and comma within string values,
consider the informat commaXw.d which applies a European convention,
reversing the role of ',' and '.'
input( '123.456,78', commax10. )
generates
123456.78
Don STanley <don.stanley@nbnz.co.nz> writes
>Hi Roland ...
>
>Not sure what you meant by this .. "It takes nearly everything you can
>throw at it.". I don't think it can interpret anything as a delimiter
>except comma, a single period (ie missing value) but not embedded
>periods, and blank -- which, as you suggest, are incredibly useful.
>
>Have you found other delimiters that it handles?
>
>I've also found that it is sometimes to clever, for example reading
>the following which was in a mis-typed file and took some time to
>track down ..
>
>data ;
> length y 8 ;
> x = '0.0 ,1' ;
> y = input(x, comma12.) ;
> put y= ;
> run ;
>
>This returns 0.01, the input file was incorrect, it should have had
>"0.0 1".
>
>Overall, its a brilliant little probably underused informat.
>
>Cheers
>Don
>
>
>"Roland" <roland@rashleigh-berry.fsnet.co.uk> wrote in message news:<big86s$4p2$
>1@newsg1.svr.pol.co.uk>...
>> I've used the comma. informat for years for reading in numbers. I love it. I
>> can always trust it. It takes nearly everything you can throw at it.
>>
>> 1 data _null_;
>> 2 str='100 000 000';
>> 3 x=input(str,comma13.);
>> 4 put x=;
>> 5 run;
>>
>> x=100000000
>> NOTE: DATA statement used:
>> real time 0.43 seconds
>>
>>
>>
>> "Alvin Igonia" <aigonia@CA.IBM.COM> wrote in message
>> news:200308261622.h7QGMMa28177@listserv.cc.uga.edu...
>> > Has anyone ever converted a string to numeric (ie. '1 000 000' to
>> 1000000).
>> >
>> > I have a program I am trying to modify. The data has change. We use to
>> > read the data string without any spaces but now it contains spaces.
>> >
>> > I don't really want to do a do-loop and check for spaces but if it's the
>> > only way, i guess i will have to.
--
Peter Crawford
Crawford Software Consultancy
UK
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic