.- help for ^mkquant^ (STB-25: sg38) .- Create quantiles and save as a new variable ------------------------------------------- ^mkquant^ varname [weight] [^if^ exp] [^in^ range]^,^ ^g^enq^(^newvar1^)^ [ ^genp(^newvar2^)^ ^n^umber^(^#^)^ ] ^aweight^s and ^fweight^s are allowed; see help @weights@. Description ----------- ^mkquant^ computes the p-th quantiles of varname, where p = i/n for i = 0, 1,..., n, with n = # an integer specified by ^number(^#^)^. The 0-th quantile is the minimum of varname and the 1-th quantile is the maximum. Options ------- ^genq(^newvar1^)^ is not optional. The quantiles are stored in the new variable newvar1. ^genp(^newvar2^)^ is optional. If specified, the corresponding empirical probabilities p = i/n will be stored in the new variable newvar2. ^number(^#^)^ specifies the number of quantiles n = #. It must be an integer. The default is 100. Examples -------- . ^mkquant price, g(quant)^ . ^mkquant price, genq(quant) n(50)^ . ^mkquant price, genq(quant) genp(p) number(200)^ . ^mkquant price, g(quant) genp(p) n(200)^ Methods and Formulas -------------------- Let the data sorted in ascending order be x(1), x(2),..., x(N), with corresponding weights w(1), w(2),..., w(N) (all equal to 1 if not specified). Let W(i) = [w(1) + w(2) + ... + w(i)]/[w(1) + w(2) + ... + w(N)]. Let q[p] be the p-th quantile of x for 0 < p < 1. | x(i) if W(i - 1) < p < W(i) q[p] = { | [(x(i) + x(i + 1)]/2 if p = W(i) We define q[0] = x(1) and q[1] = x(N). Author ------ Bill Sribney Stata Corporation 702 University Drive East College Station, TX 77840 Phone: 409-696-4600 800-782-8272 Fax: 409-696-4601 email: stata@@stata.com Also see -------- STB: STB-25 sg38 Manual: [5s] centile, [5s] egen, [5s] summarize On-line: help for @centile@, @egen@, @summarize@