LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous (more recent) messageNext (less recent) messagePrevious (more recent) in topicNext (less recent) in topicPrevious (more recent) by same authorNext (less recent) by same authorPrevious page (November 2005, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Thu, 3 Nov 2005 12:02:25 -0600
Reply-To:     PuddingDotManAtGmailDotCom@listserv.cc.uga.edu
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Pudding Man <pudding.man@GMAIL.COM>
Subject:      Re: Trying to avoid division by zero...
Comments: To: Kevin Myers <KMyers@procominc.net>
In-Reply-To:  <01e801c5dff0$85f15d20$6502a8c0@speedy>
Content-Type: text/plain; charset=ISO-8859-1

On 11/2/05, Kevin Myers <KMyers@procominc.net> wrote: > By the way, here is an only slightly uglier macro to get around division by > zero messages within expressions, if you really need to: > > %macro zdiv(n,d); > ifn(&d,(&n)/ifn(&d,&d,1),.) > %mend zdiv; > > Usage example: > > data _null_; > do d=0 to 5; > r=%zdiv(1,d); > put d= r=; > end; > run;

--- snip ---

It is very clever (compliments).

It works!

It seems to use about 2.6 times the cpu cycles of an equivalent IF/THEN/ELSE construct in a simple test. Particularly for folks that have neither beau coup fractions to compute nor tons of data, performance would not be an issue.

Cheers, Puddin'

***************************************************************** *** Puddin' Man PuddingDotMan at GmailDotCom ** *****************************************************************;


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