This is a Windows 64bit environment.
When the following program is executed, the
data _null_;
value=12345678;
put 'best4.> ' value best4. /
'best5.> ' value best5. /
'best6.> ' value best6. /
'best7.> ' value best7.;
run;
The results are as follows
best4.> 12E6 best5.> 123E5 best6.> 1.23E7 best7.> 1.235E7
Here we see that
Why does best5 format print as 123E5 instead of 1.2E7?
Why does best6 format print as 1.23E7 instead of 1234E4?
I can't figure it out by looking at Help.
The printed results of best5 format. and best6. are different in expression, but they have the same value, right?(12300000)
Since the length of the format changes, doesn't the number of significant digits also change?
Why is it that the number of significant digits changes, but the actual value is the same?
I don't get it.
If anyone knows, please let me know.
The logic as length grows seems to be: Add significant digits, when you have 3 significant digits, add a decimal point, and then add more digits.
That's just what the format does.
The BEST format exponential notation doesn't care about "significant digits" as so many users have different rules for what is significant.
If you care, then do not use BEST formats which uses general rules, based on ranges of values, to display values within a fixed number of characters. Use the E format if want to control things a bit better.
You should include negative values when playing with such examples as well to see what effect the extra character for negative does to values.
The idea of the BEST format is that it will pick the best way to display the value in the number of characters you requested. "123E5" is better than "1.2E7" because by eliminating the decimal point it can include one extra digit and still fit into only 5 characters.
You would have to talk to SAS about how SAS decides what is "BEST".
The idea of the BEST format is that it will pick the best way to display the value in the number of characters you requested. "123E5" is better than "1.2E7" because by eliminating the decimal point it can include one extra digit and still fit into only 5 characters.
Based on your way of thinking, it seems that 1234E4 would be superior to 1.23E7.
You would have to talk to SAS about how SAS decides what is "BEST".
I think that's exactly right, but this kind of "specification" is not disclosed to the public.
So, I tried to guess from the results, but I couldn't figure it out.
And given how SAS normally maintains backwards compatibility they are not likely to change the algorithm to start having 12345678 display with BEST6. as "1234E4" instead of "1.23E7".
The logic as length grows seems to be: Add significant digits, when you have 3 significant digits, add a decimal point, and then add more digits.
That's just what the format does.
That tends to be the case.
The rest seems to depend on the value, as shown below.
data _null_;
a=10000;
put a=best4.;
a=11000;
put a=best4.;
run;
Results:
a=1E4 a=11E3
lol
zeros are not significant digits then...
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.