I have been trying to get the round function to feed some locals that I use to create graphs labels, however, rounding has proven particularly challenging, as this actual example illustrates
. qui centile variable if year==2007, c(10 25 40 50 60 75 90)
. local pop=r(N)
. count if variable==0 & year==2007
2,657
. local zeros=r(N)
. local ptile = 100*round(`zeros'/`pop',0.0001)
. di "zero ptile=`ptile'"
zero ptile=84.54000000000001
. local ptile = round(100*`zeros'/`pop',0.0001)
. di "zero ptile=`ptile'"
zero ptile=84.54000000000001
As you see, this is not nice rounding. When I try to use this function to label my graphs and other things I don''t know how to overcome this problem. Can anyone tell me how??
Probably this has been solved before, but I have not being able to find how to solve this matter so I woudl appreciate if I am pointed the right forum too.
Related Posts with Rounding, multiple decimals off and Locals
how to get numeric, not characters, return values from programmingDear all, I've written the following programming to extract b, t-stat, etc. after estimating a regr…
access to a column (and a row) of matrixDear all, Is there a way to get access to a column of matrix and display it? I see that there is a …
ASCVD risk calculators in stataHello, I am trying to estimate ascvd risks using the 2013 AHA/ACC pooled cohort equation, referenced…
Assigning a dummy based on previous roleDear all, I am trying to accomplish a (I think) rather simple task but I just cannot seem to get th…
Chow test where most controls are factor/ categorical variablesI am doing Chow test to compare coefficients of two separate groups of samples. Such as male/ female…
Subscribe to:
Post Comments (Atom)
0 Response to Rounding, multiple decimals off and Locals
Post a Comment