Is that a typo? round(3.1415, 1.2) = 3.6, not 2.6
As far as round(3.1415,1.5), 3 is the closest multiple of 1.5 to the value 3.1415
Hi @duckduckgo, according to the documentation on the ROUND function, it rounds the first argument to the nearest multiple of the second argument. The nearest multiple of 1.2 is 3.6 (I believe this was a typo in your original message) and the nearest multiple of 1.5 is indeed 3.
Is that a typo? round(3.1415, 1.2) = 3.6, not 2.6
As far as round(3.1415,1.5), 3 is the closest multiple of 1.5 to the value 3.1415
When you use the ROUND function SAS attempts to display the first argument as the nearest multiple of the second. The only possible multiples for any value rounded to 1.5 are 0, 1.5, 3, 4.5, 6, etc.
Round is not division, which seems to be what you are interpreting this to be.
Consider this example:
data example; x1 = round(3.1415,1.45); x2 = round(3.1415,1.46); x3 = round(3.1415,1.47); x4 = round(3.1415,1.48); x5 = round(3.1415,1.49); x6 = round(3.1415,1.5); x7 = round(3.1415,1.51); x8 = round(3.1415,1.52); run;
The nearest value to 3.1415 of a multiple of 1.45 is 2*1.45 or 2.9. of 1.46 is 2*1.46 or 2.92 ... 2*1.5=3
If you are playing around with Pi you may want to consider looking up the CONSTANT function to return better values of some constant values such as pi.
Ready to level-up your skills? Choose your own adventure.