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 (May 2004, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Mon, 24 May 2004 15:03:15 -0700
Reply-To:     cassell.david@EPAMAIL.EPA.GOV
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         "David L. Cassell" <cassell.david@EPAMAIL.EPA.GOV>
Subject:      Re: Help working with very small decimals
Content-type: text/plain; charset=US-ASCII

Mark Biek <markb@STEVENSONCOMPANY.COM> wrote: > I'm doing some calculations where I end up with numbers like > 2.20116E-05 and 5.96576E-08. The problem is that these numbers all just > show up as 0 in my dataset. > > I've tried formatting and using length but it either doesn't work or I > don't understand how to do it. > > What do I need to do to get more decimal places?

Well, first of all, the LENGTH statement will not help you. It doesn't control the display format of a number. It controls the number of characters to use for string variables, and the hard drive storage details of numeric variables. That is not what you want.

Formats are what you want. But you say you didn't get that to work. Perhaps you ought to show the list what code you actually tried. Here is some sample code which shows how you might want to use the FORMAT statement:

data temp1; input x; datalines; 1 1000 2.20116E-05 5.96576E-08 ; run;

/* Okay, now you have the data. SAS saved everything. But maybe you are not displaying it correctly. Let us see... */

proc print; run;

/* The output looks like this:

Obs x

1 1.00 2 1000.00 3 0.00 4 0.00

Now we have the zeroes you were concerned about. But this is just because you have not displayed the saved data correctly. */

proc print; format x best10.; run;

/* Now the output looks like:

Obs x

1 1 2 1000 3 0.00002201 4 5.96576E-8

Now we can see the results better. But the ten characters for display means that some of the small numbers show as scientific notation, and some don't. */

proc print; format x best14.; run;

/* Now the output looks like:

Obs x

1 1 2 1000 3 0.0000220116 4 5.96576E-8

More places, but this still won't help for all possible small decimals. */

proc print; format x 12.8; run;

/* Now the output looks like:

Obs x

1 1.00000000 2 1000.0000000 3 0.00002201 4 0.00000006

Okay, things look uniform, but we lose precision on both small decimals. */

You may also want to look at the Ew. and Dw.s formats to get the right look for your output. But the important part is that your numbers are still preserved in the SAS data set, even if you don't show them well in your outputs.

HTH, David -- David Cassell, CSC Cassell.David@epa.gov Senior computing specialist mathematical statistician


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