Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best SAS formats to be used for numbers with lots of digits before and after decimal

Tags:

sas

I would like to read and display numbers like below using infile statement -

  • 0.02133322413531
  • 25895449673.5189
  • 190848802804.89248974

without loosing any of the digits ( significant and non significant both) from a flat file which are the best formats to use in for - input , informat and format.

EDIT:

Have tried below so far, digits getting truncated for the last one , rest two are coming fine

data _null_;
infile datalines;
format x BEST32.;
input x : BEST32.;
put x=;
datalines;
0.02133322413531
25895449673.5189
190848802804.89248974
;
run;

Output:

  • x=0.02133322413531
  • x=25895449673.5189
  • x=190848802804.892 <--- Getting truncated
like image 727
in_user Avatar asked Sep 16 '25 08:09

in_user


1 Answers

At the default numeric length of 8 bytes, SAS can only accurately store floating point values to approximately 15 digits. This link best describes the reasons for this.

Or for further light reading, this link provides more detailed information

like image 191
Longfish Avatar answered Sep 19 '25 13:09

Longfish