Date: Tue, 24 Mar 2009 09:53:11 -0500
Reply-To: Joe Matise <snoopy369@GMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Joe Matise <snoopy369@GMAIL.COM>
Subject: Re: reducing the length of numeric variable
In-Reply-To: <b7a7fa630903240752u1f823b7ewe22cf4d2daec732a@mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1
Small correction to my explanation ... you either want to truncate the
number, or reduce its formatted length; you do not want to reduce the number
of bytes used to store the number (length), as that can have accuracy
complications beyond that of simple truncation.
-Joe
On Tue, Mar 24, 2009 at 9:52 AM, Joe Matise <snoopy369@gmail.com> wrote:
> First off, you don't want to reduce the length (storage space used), as
> that reduces accuracy. You want to reduce the format length.
>
> Do you want it rounded? It looks like you don't, but keep that in mind.
>
> Simply formatting it to
> format cov4 5.3
> will show what you indicate below. Depending on how you output it to the
> other program, that may work.
>
> If not (if you're passing a dataset and not proc printing it or otherwise
> using output), you need to use
> cov_4 = floor(1000*cov_4)/1000
> or
> round (floor,.001)
> the latter will actually round it, not just truncate it.
>
> -Joe
>
>
> On Tue, Mar 24, 2009 at 9:37 AM, vrajeshrawal@gmail.com <
> vrajeshrawal@gmail.com> wrote:
>
>> My cov_4 variable looks like
>>
>> cov_4
>> 2.3164977635316
>> 3.1546584777797
>> 4.4646674776444
>> 5.1646466797979
>>
>> I want it to look like
>>
>> cov4
>> 2.316
>> 3.154
>> 4.464
>> 5.164
>>
>> I want to do this because I want to use the output file by some other
>> software.
>>
>
>
|