Date: Fri, 26 Sep 2008 10:05:55 -0400
Reply-To: Samuel Croker <samuel.croker@GMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Samuel Croker <samuel.croker@GMAIL.COM>
Subject: Re: hi all,
I to find prime number using Macro program and using base SAS.
Content-Type: text/plain; charset=ISO-8859-1
This is interesting and as you try to get large you will hit the limit of
precision in data step sas. For example:
SAS integer limit:
C++ unsigned long long:
This first came up when I tried to replicate , as an academic exercise,
RANNOR using the datastep and a PIT. I couldn't match the results and
realized that RANNOR is using a precision in the routine that is
unattainable in the data step. You could probably program it using LCGs or
some other technique like that designed to get around numeric precision
here is an interesting prime site http://primes.utm.edu/curios/
there are lots of optimized routines for prime identification out there.
On Fri, Sep 26, 2008 at 9:37 AM, Anthony Steel <
> When dealing with larger primes you could improve the efficiency of the do
> loop by setting the range of j to be 2 to the square root of i, as this
> will still encompass all possible factors of i.
> On Fri, 26 Sep 2008 06:15:01 -0700, Dirk Nachbar <dirknbr@GOOGLEMAIL.COM>
> >On Sep 26, 4:55 am, Satya <kondal4u...@gmail.com> wrote:
> >> hi all
> >> I to find prime number from 1 to 20 using Macro program and using
> >> base SAS.
> >> I tried but that code is some how big .
> >> Bye.
> >here is ths solution
> >option mprint;
> >%macro prime(n);
> >data prime;
> >do i=1 to &n;
> > prime=1;
> > do j=2 to ceil(i/2);
> > if mod(i,j)=0 then prime=0;
> > end;
> > if prime=1 then output;
Samuel T. Croker