Say I wanted to return the number .6705583000000001 with at most 7 digits to the right of the decimal point. The following seems to be useful:
Code:
. local x = .6705583000000001 . disp `=`"`:di %9.7f `x''"'' .6705583 . disp round(`x', 0.0000001) .6705583
Code:
. program define testprog, rclass 1. args x 2. return scalar test = `=`"`:di %9.7f `x' '"'' 3. return scalar test2 = round(`x', 0.0000001) 4. end . . . testprog .6705583000000001 . return list scalars: r(test2) = .6705582999999999 r(test) = .6705583000000001
0 Response to Controlling the format of scalars in return list
Post a Comment