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 2003, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Thu, 20 Nov 2003 11:27:42 -0500
Reply-To:     "Richard A. DeVenezia" <radevenz@IX.NETCOM.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         "Richard A. DeVenezia" <radevenz@IX.NETCOM.COM>
Subject:      Re: Constant for PI in SAS?

"Droogendyk, Harry" <Harry.Droogendyk@CIBC.COM> wrote in message news:F0161D3F7AC5D411A5BE009027E774D60E61C6DB@gemmrd-scc013eu.gem.cibc.com... > See the constant() function in Online Docs > > -----Original Message----- > From: Sarah Presley [mailto:gosarah@YAHOO.COM] > Sent: November 20, 2003 10:24 AM > To: SAS-L@LISTSERV.UGA.EDU > Subject: Constant for PI in SAS? > > Does SAS have a symbol or constant for PI, or should I just > create my own? > > Thanks. >

Small warning on use of constant() in a loop, don't. The data step compiler does not recognize and optimize a constant() call with a constant argument.

%let max=1e8; * drop this down a magnitude if not on very fast (circa 2003) system;

* inside, slow; * compiler demonstrating unsmarts; data _null_; do p = 1 to &max; theta = 2*constant('PI') * p/&max; end; stop; run;

* outside, fast; * a nobrainer compiler should at worst optimize inside,slow to something like this; data _null_; pi = constant ('PI'); do p = 1 to &max; theta = 2*pi * p/&max; end; stop; run;

* compiled as constant inside, faster; data _null_; do p = 1 to &max; theta = 2*%sysfunc(constant(PI)) * p/&max; end; stop; run;

* all constant expression fully resolved prior to compilation, fasterer than faster ! * I am very surprised by this. I would have expected the compiler to do full constant resolution on its own!; data _null_; do p = 1 to &max; theta = %sysevalf(2*%sysfunc(constant(PI))/&max) * p; end; stop; run;

slow to fast continuum observed in both 8.2 and 9.0 during repeated runs on a Windows 2000 machine on P4 3.06g and 1g of 333mhz memory.

I am particularly disturbed that the compiler is not exhibiting smarts. This lack of smarts has nothing to do with constant() function and is fundamental in nature.

-- Richard A. DeVenezia http://www.devenezia.com


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