Dear Statalist,
I am trying to compute percentiles across distinct values of a given variable.
A possible approach, as exemplified in this topic was to write something like this:
However, Stata 13 apparently does not recognize anymore this syntax:
or the alternative:
I thought then to loop over values of weight_group:
but the loop fails to assign percentiles by weight_group as it can be verified by comparing mpg_group_0 with mpg_group_1.
Any hints on any alternative syntax or possible solution? Thank you very much.
Andre
I am trying to compute percentiles across distinct values of a given variable.
A possible approach, as exemplified in this topic was to write something like this:
Code:
egen mpg_group = xtile(mpg), by(weight_group) nq(3)
Code:
unknown egen function xtile()
Code:
. bysort weight_group: gen mpg_group = xtile(mpg) unknown function xtile()
Code:
levelsof weight_group, local(levels2) foreach k of local levels2 { xtile mpg_group_`k' = mpg, nq(3) } *
Code:
corr mpg_group_0 mpg_group_1 sort mpg_group* weight_group order mpg_group* weight_group mpg, last
Andre
Comment