Date: Fri, 26 Oct 2001 13:58:31 -0700
Reply-To: Dale McLerran <dmclerra@MY-DEJA.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Dale McLerran <dmclerra@MY-DEJA.COM>
Subject: Re: Character to numeric conversion
Content-Type: text/plain
John,
I ran your code on an NT box under 6.12, increasing the number of
iterations on i by a factor of 10. Under 6.12, I get results
consistent with your results. The implicit conversion took 24.31
seconds while the explicit conversion took 24.57 seconds. A
second running of the code took 24.31 and 24.55 seconds, so the
results appear to be quite consistent. I also submitted the job
under version 8.2. The implicit conversion required 10.25 and
10.26 seconds for two repetitions of the job, while the explicit
conversion required 8.55 and 8.57 seconds. Once again, the results
are very consistent.
I also ran the code twice under each version of SAS, commenting out
the conversion part. Under version 6.12, the time to perform the
looping was 7 seconds. Under version 8.2, the time to perform the
looping was 2.37 seconds. Subtracting these times from our previous
time values gives the time required to perform the conversions
under each version of SAS. Under 6.12, the implicit conversions
require 17.3 seconds while the explicit conversions require 17.56
seconds. Under version 8.2, then implicit conversions require 7.9
seconds, while the explicit conversions require 6.2 seconds.
Now, we can draw a couple of conclusions here:
1) version 8.2 has increased performance remarkably over that of
version 6.12 for both operations all of the operations examined
here (looping along with implicit and explicit conversions)
2) while there was an extremely small benefit of the implicit
conversion under 6.12, the explicit conversion is more efficient
under 8.2.
Dale
>Date: Fri, 26 Oct 2001 20:21:13 +0100
> Dale McLerran <dmclerra@my-deja.com>, SAS-L@LISTSERV.UGA.EDU John Whittington <John.W@mediscience.co.uk> Re: Character to numeric conversion
>At 09:40 26/10/01 -0700, Dale McLerran wrote:
>
>>.... I would recommend that you not employ implicit type conversion using
>>the multiply by 1 approach which you mention. That is an inefficient
>>approach. It is better to use explicit type conversion.
>
>Dale, I think we've been through this one before! - it really depends upon
>what one means by 'inefficient'. I think we can probably all agree that
>implicit conversion is not very good programming practice, not the least
>because it undermines the value of 'implicit conversion messages' in the
>log as a useful means of flagging programming errors - and therefore many
>result is wastage of user time ('inefficient'). However, if you are
>talking about efficiency in terms of run-time execution speed, then, if
>anything, implicit conversion seems to slightly 'win' (following log from
>SAS 8.2 on steam-powered Win95 PC):
>
>670 data _null_ ;
>671 c = '6' ;
>672 start = time() ;
>673 do i = 1 to 1e7 ;
>674 n = c * 1 ;
>675 end ;
>676 elapse = time() - start ;
>677 put 'time taken = ' elapse 5.2 ' seconds' ;
>678 run ;
>
>NOTE: Character values have been converted to numeric values at the places
>given by:
> (Line):(Column).
> 674:11
>time taken = 13.57 seconds
>NOTE: DATA statement used:
> real time 13.61 seconds
>
>679 data _null_ ;
>680 c = '6' ;
>681 start = time() ;
>682 do i = 1 to 1e7 ;
>683 n = input(c, best32.) ;
>684 end ;
>685 elapse = time()-start ;
>686 put 'time taken = ' elapse 5.2 ' seconds' ;
>687 run ;
>
>time taken = 14.00 seconds
>NOTE: DATA statement used:
> real time 14.06 seconds
>
>Kind Regards,
>
>
>John
>
>----------------------------------------------------------------
>Dr John Whittington, Voice: +44 (0) 1296 730225
>Mediscience Services Fax: +44 (0) 1296 738893
>Twyford Manor, Twyford, E-mail: John.W@mediscience.co.uk
>Buckingham MK18 4EL, UK mediscience@compuserve.com
>----------------------------------------------------------------
---------------------------------------
Dale McLerran
Fred Hutchinson Cancer Research Center
mailto: dmclerra@fhcrc.org
Ph: (206) 667-2926
Fax: (206) 667-5977
---------------------------------------
------------------------------------------------------------
--== Sent via Deja.com ==--
http://www.deja.com/
|