LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (October 2001, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Fri, 26 Oct 2001 20:21:13 +0100
Reply-To:     John Whittington <John.W@MEDISCIENCE.CO.UK>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         John Whittington <John.W@MEDISCIENCE.CO.UK>
Subject:      Re: Character to numeric conversion
Comments: To: Dale McLerran <dmclerra@MY-DEJA.COM>
In-Reply-To:  <E15xA5k-000117-00@relay1.netnames.net>
Content-Type: text/plain; charset="us-ascii"; format=flowed

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 ----------------------------------------------------------------


Back to: Top of message | Previous page | Main SAS-L page