The SAS Output Delivery System and reporting techniques

Displaying exact value in BASE SAS

Reply
Contributor
Posts: 21

Displaying exact value in BASE SAS

Hi,

I notice when i use SAS base, it will round the figure if it is more than 18 digit.

Is there any setting in server/client machine if we want to show exact value?

Please advice. Thank you.

Following are the sample code i use

data test;

format b best32.;

format d best32.;

format f best32.;

x = '0010000000130000123';

y = '001000000013000012';

z = '00100000001300001';

len1 = length(x);

len2 = length(y);

len3 = length(z);

b = input(x, best32.);

d = input(y, best32.);

f = input(z, best32.);

run;


Result1.jpg
Super Contributor
Posts: 307

Re: Displaying exact value in BASE SAS

There are limitations on the storage of large numbers. See the discussion on numeric precision at SAS(R) 9.2 Language Reference: Concepts, Second Edition.


If you aren't using the number for mathematical operations, why not leave it as text?

If you are doing mathematical operations, then SAS floating point representation might be good enough?

If you insist on storing the entire number, try the w.d informat. And don't use the BEST format. The downside is increased disk space. You could use the COMPRESSION=BINARY option to offset this.

data test;

format b c d 32.;

x = '0010000000130000123';

y = '001000000013000012';

z = '00100000001300001';

len1 = length(x);

len2 = length(y);

len3 = length(z);

b = input(x, 32.);

c = input(y, 32.);

d = input(z, 32.);

run;

Contributor
Posts: 21

Re: Displaying exact value in BASE SAS

Hi,

After added command option COMPRESS=BINARY; in our script and the outcome still the same, still round the value to 0010000000130000124.

I'm using SAS 9.1.3. Is there any difference between SAS 9.2 and SAS 9.1.3?



Valued Guide
Posts: 3,208

Re: Displaying exact value in BASE SAS

mikesatriavo, 

Did you read teh reference fugue had given? SAS(R) 9.4 Language Reference: Concepts (Numeric Precision in SAS Software). The title here is wrong it is not SAS related as it applies to all kind of floating processing (flops). It is IEE standard.

This is something as fundamental to calculations for a very very long time. Floatings are by definition not precise.          

Compressing is just a method for saving dasd space doesn't have any effect to numeric precision (length max=8 has).

The remark on handling as character is also sensible.

- The average on female=1 male=2 makes no sense as it is a classification.

- IBAN numbers are even no numbers.  

The way of limiting to numbers at sme areas is going back to the old hollerith age having visible 10 columns.

Working on a DBMS with those many more datatypes, there is a new language added in SAS (9.3 last uypdates, 9.4) "PROC DS2" http://support.sas.com/documentation/cdl/en/proc/64787/HTML/default/viewer.htm#n08hc15x330v75n1vjw9r...

---->-- ja karman --<-----
Occasional Contributor
Posts: 19

Re: Displaying exact value in BASE SAS

Hi! What kind of data or problem do you have, since you consider that the data values have 18 correct digits ?
In real life the relative error in the numbers is often quite big. I would guess that it is very unusual to have more than 7 or 8 correct digits in measured values. Even in cases where you have many correct digits, they are often not of interest.
Of course Bank account numbers etc. are longer - but they are not measured values. They should be stored as characters.
Jaap and others above have given very good and detailed technical answers.

/ Br Anders Sköllermo (Andrew Skollermo in English)

Anders Sköllermo
Ph.D., Swedish Actuary

"Both Age and IQ are 69+"
"Retired, But Not Tired"

Sandgränd 13, S-178 40 Ekerö
email: anders.skollermo@one.se
tele: 00468968419 mobil: 0046735077373
Super User
Posts: 5,369

Re: Displaying exact value in BASE SAS

This is a known SAS limitation, with a recent discussion here:

https://communities.sas.com/thread/48679

Good luck.

Ask a Question
Discussion stats
  • 5 replies
  • 933 views
  • 0 likes
  • 5 in conversation