From: vncntj on
I have:

length = 0.20 + 0.05 * ranuni(0);

but I'm trying to limit the value to 2 decimal places instead of

0.2499872231

trimmed to

0.24

Thanks
From: Barry Schwarz on
For n decimal places, multiply by 10^n, take the integer portion of
the answer, and then divide by 10^n.

Of course, you are aware that values like .24 can never be represented
exactly in binary (just as 1/3 can never be represented exactly in
decimal). But the approximation used by SAS will be much closer than
..24998...

On Sat, 17 Apr 2010 04:38:17 -0700 (PDT), vncntj
<vincent.s.jones(a)gmail.com> wrote:

>I have:
>
> length = 0.20 + 0.05 * ranuni(0);
>
>but I'm trying to limit the value to 2 decimal places instead of
>
>0.2499872231
>
>trimmed to
>
>0.24
>
>Thanks

--
Remove del for email
From: Tom Abernathy on
On Apr 17, 7:38 am, vncntj <vincent.s.jo...(a)gmail.com> wrote:
> I have:
>
>  length = 0.20 + 0.05 * ranuni(0);
>
> but I'm trying to limit the value to 2 decimal places instead of
>
> 0.2499872231
>
> trimmed to
>
> 0.24
>
> Thanks

Are you looking for the ROUND function?
To round to the nearest hundredth you would do this:

length=round(length,0.01);
From: Patrick on
Hi
The following gives you random numbers with 2 decimals between 0.20
and 0.25:

length=0.20 + ceil(ranuni(0)*5)/100;

HTH
Patrick
From: Patrick on
Ooops! Forgot about 0. That's the correct code:

length=0.20 + floor(ranuni(0)*6)/100;