Radu Ban
> I have computed a lot of centiles (44 to be more exact) for
> a variable and I
> was wondering if there is a quick way to recall the
> requested centiles.
> I know the requested centiles are stored in a
> macro - r(centiles) but I don't know how to recall them separately.
The documentation on this -- I take it Radu is referring to
-centile- -- is terse and to see what is going on you need to issue
. return list
after a -centile- command.
r(centiles) just echoes what you asked for in the -centile()-
option. The values of the centiles are in r(c_1), r(c_2), etc.
This example shows some techniques which may be pertinent.
. qui centile mpg, c(5 10 25 50 75 90 95)
. ret li
scalars:
r(n_cent) = 7
r(N) = 74
r(ub_7) = 40.82632136492616
r(lb_7) = 28.68068344901154
r(c_7) = 34.25
r(ub_6) = 34.79482196757711
r(lb_6) = 26
r(c_6) = 29.5
r(ub_5) = 26.07109169597815
r(lb_5) = 22.43244200253517
r(c_5) = 25
r(ub_4) = 22
r(lb_4) = 19
r(c_4) = 20
r(ub_3) = 18
r(lb_3) = 16
r(c_3) = 17.75
r(ub_2) = 16
r(lb_2) = 14
r(c_2) = 14
r(ub_1) = 14.31931655098844
r(lb_1) = 12
r(c_1) = 14
macros:
r(centiles) : "5 10 25 50 75 90 95"
. tokenize `r(centiles)'
. local nc : word count `r(centiles)'
. forval i = 1 / `nc' {
2. di "centile `i' (``i'' percentile) is " r(c_`i') }
centile 1 (5 percentile) is 14
centile 2 (10 percentile) is 14
centile 3 (25 percentile) is 17.75
centile 4 (50 percentile) is 20
centile 5 (75 percentile) is 25
centile 6 (90 percentile) is 29.5
centile 7 (95 percentile) is 34.25
Nick
[email protected]
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/