in_user
in_user

Reputation: 1958

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

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

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:

Upvotes: 4

Views: 4635

Answers (2)

jaamor
jaamor

Reputation: 317

If you store the numbers as a character variable you will not lose any of the digits.

Every time you perform a calculation you could use the input function to convert to a numeric.

 input(number_string,format.)

Also if you use Data Step 2 (DS2) then you are not limited to the two datatypes, you could also use decimal(p,q), where (p,q) the digits to the left and right of the decimal point, that can be up to 52.

Upvotes: 0

Longfish
Longfish

Reputation: 7602

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

Upvotes: 8

Related Questions