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 (November 2010, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Sat, 6 Nov 2010 14:06:56 -0700
Reply-To:   Daniel Nordlund <djnordlund@FRONTIER.COM>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   Daniel Nordlund <djnordlund@FRONTIER.COM>
Subject:   Re: do loops and math formula
In-Reply-To:   <000001cb7def$c23ffbe0$46bff3a0$@com>
Content-Type:   text/plain; charset="utf-8"

> -----Original Message----- > From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of > bbser2009 > Sent: Saturday, November 06, 2010 1:18 PM > To: SAS-L@LISTSERV.UGA.EDU > Subject: do loops and math formula > > Hi there, > > > > Say computing annual investment earnings, we can either using a do loop or > a > formula like this: > > earned=capital*(1+rate)**12-capital; > > > > I was wondering, which way was more efficient in terms of execution time? > > Thanks. > > Max

In general, a single formula is going to be more efficient than looping, but then you haven't given us any information about where the variables capital and rate are coming from. Also, we don't know what the structure of the loop is, or what variables it would be operating on, or where the data is coming from.

If you gave a toy example, we could give make more accurate statements about which would be faster.

Dan

Daniel Nordlund Bothell, WA USA


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