- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I've tried outputting best1-32 for various numbers, negative numbers of course, and numbers with decimals, but I couldn't figure out the law at all.
I don't want to know how to display the values, I simply want to know the law of exponential notation in BEST format.
Why? Is it because I am a spec idiot? 😛
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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".
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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".
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
zeros are not significant digits then...