@Tom wrote:
Since in this case you are generating a data step anyway you can just use SAS for all of your calculations. Which means you can just use a FORMAT to do the rounding of the values you write to the LOG.
This is an excellent point from @Tom . Rounding using a FORMAT is often superior to rounding using the ROUND function. Why? Because if these are intermediate calculations that will be used later in the program in a further analysis, rounding using the ROUND function can lead to incorrect answers in later steps that use that variable. Using the FORMAT does not truncate the value and so later steps still can use the entire collection of digits in the value, leading to correct answers.
Of course, I feel that too many people focus so tightly on the coding problem that they have a problem with, and don't explain how the answers will be used. This is a sub-optimal method, and can lead to sub-optimal answers. @dxiao2017 : We need to know the big picture, not just the coding problem you have. If we know the big picture, we won't give you answers that don't work in the big picture. If we know the big picture, we can also advise on better approaches and logic (which can be easier to program and a better method) to get you to your final result. This is called the XY-problem. Please read about the XY-problem (here and here).
Side issue: there are times when ROUNDing is the right thing to do, but without knowing the big picture, we can't even begin to advise you on this.
... View more