The STDIZE Procedure

Computing Quantiles

PROC STDIZE offers two methods for computing quantiles: the one-pass approach and the order-statistics approach (like that used in the UNIVARIATE procedure).

The one-pass approach used in PROC STDIZE modifies the $\mr{P}^2$ algorithm for histograms proposed by Jain and Chlamtac (1985). The primary difference comes from the movement of markers. The one-pass method allows a marker to move to the right (or left) by more than one position (to the largest possible integer) as long as it does not result in two markers being in the same position. The modification is necessary in order to incorporate the FREQ variable.

You might obtain inaccurate results if you use the one-pass approach to estimate quantiles beyond the quartiles (that is, when you estimate quantiles < P25 or quantiles > P75). A large sample size (10,000 or more) is often required if the tail quantiles (quantiles $\le $ P10 or quantiles $\ge $ P90) are requested. Note that, for variables with highly skewed or heavy-tailed distributions, tail quantile estimates might be inaccurate.

The order-statistics approach for estimating quantiles is faster than the one-pass method but requires that the entire data set be stored in memory. The accuracy in estimating the quantiles is comparable for both methods when the requested percentiles are between the lower and upper quartiles. The default is PCTLMTD=ORD_STAT if enough memory is available; otherwise, PCTLMTD=ONEPASS.

Computational Methods for the PCTLDEF= Option

You can specify one of five methods for computing quantile statistics when you use the order-statistics approach (PCTLMTD=ORD_STAT); otherwise, the PCTLDEF=5 method is used when you use the one-pass approach (PCTLMTD=ONEPASS).

Percentile Definitions

Let n be the number of nonmissing values for a variable, and let $x_1, x_2, \ldots , x_ n$ represent the ordered values of the variable. For the tth percentile, let $p = t/100$. In the following definitions numbered 1, 2, 3, and 5, let

\[  \mathit{np} = j + g  \]

where j is the integer part and g is the fractional part of np. For definition 4, let

\[ (n+1)p = j + g \]

Given the preceding definitions, the tth percentile, y, is defined as follows:

PCTLDEF=1

weighted average at $x_{\mathit{np}}$

\[  y = (1 - g)x_ j + gx_{j+1}  \]

where $x_0$ is taken to be $x_1$

PCTLDEF=2

observation numbered closest to np

\[ y = x_ i \]

where i is the integer part of $\mathit{np} + 1/2$ if $g \neq 1/2$. If $g=1/2$, then $y=x_ j$ if j is even, or $y=x_{j+1}$ if j is odd

PCTLDEF=3

empirical distribution function

\[  y = x_ j ~  \mr{if~ } g = 0  \]
\[  y=x_{j+1}~  \mr{if~ } g > 0  \]
PCTLDEF=4

weighted average aimed at $x_{p(n+1)}$

\[  y=(1 - g)x_ j + gx_{j+1}  \]

where $x_{n+1}$ is taken to be $x_ n$

PCTLDEF=5

empirical distribution function with averaging

\[  y = (x_ j + x_{j+1})/2 ~  \mr{if~ } g = 0  \]
\[  y = x_{j+1}~  \mr{if~ } g > 0  \]

Weighted Percentiles

When you specify a WEIGHT statement, or specify the NOTRUNCATE option in a FREQ statement, the percentiles are computed differently. The 100pth weighted percentile y is computed from the empirical distribution function with averaging

\[  y = \left\{  \begin{array}{cl} \frac{1}{2} ( x_ i + x_{i+1} ) &  \mr{if} \sum _{j=1}^{i} w_ j = pW \\ x_{i+1} &  \mr{if} \sum _{j=1}^{i} w_ j < pW < \sum _{j=1}^{i+1} w_ j \end{array} \right.  \]

where $w_ i$ is the weight associated with $x_ i$, and where $W = \sum _{i=1}^{n} w_ i$ is the sum of the weights.

For PCTLMTD= ORD_STAT, the PCTLDEF= option is not applicable when a WEIGHT statement is used, or when a NOTRUNCATE option is specified in a FREQ statement. However, in this case, if all the weights are identical, the weighted percentiles are the same as the percentiles that would be computed without a WEIGHT statement and with PCTLDEF=5.

For PCTLMTD= ONEPASS, the quantile computation currently does not use any weights.