QNTL Call

CALL QNTL (q, x, <, probs> <, method> ) ;

The QNTL subroutine computes sample quantiles for data. The arguments are as follows:

q

specifies a matrix to contain the quantiles of the x matrix.

x

specifies an $n\times p$ numerical matrix of data. The QNTL subroutine computes quantiles for each column of the matrix.

probs

specifies a numeric vector of probabilities used to compute the quantiles. If this option is not specified, the vector $\{ 0.25, 0.5, 0.75\} $ is used, resulting in the quartiles of the data. For convenience, a probability of 0 returns the minimum value of x, and a probability of 1 returns the maximum value.

method

specifies the method used to compute the quantiles. These methods correspond to those defined by using the PCTLDEF= option in the UNIVARIATE procedure. For details, see the section Calculating Percentiles of the documentation for the CORR procedure in the Base SAS Procedures Guide: Statistical Procedures.

The following values are valid:

1

specifies that quantiles are computed according to a weighted average.

2

specifies that quantiles are computed by choosing an observation closest to some quantity.

3

specifies that quantiles are computed by using the empirical distribution function.

4

specifies that quantiles are computed according to a different weighted average.

5

specifies that quantiles are computed by using average values of the empirical distribution function. This is the default value.

If x is an $n\times p$ matrix, the QNTL subroutine computes a $k\times p$ matrix where $k$ is the dimension of the probs matrix. The quantiles are returned in the q matrix, as shown in the following example:

x = {5 1 10,
     6 2 3,
     6 8 5,
     6 7 9,
     7 2 13};
call qntl(q, x);
print q[rowname={"P25", "P50", "P75"}];

Figure 24.280: Quantiles

q
P25 6 2 5
P50 6 2 9
P75 6 7 10


You can use the MATTRIB statement to permanently assign row names to the matrix that contains the quantiles, as shown in the following statements:

p = {0.25 0.50 0.75};
labels = "P" + strip(putn(100*p, "best5."));
mattrib q rowname=labels;
print q;

Figure 24.281: Rownames for Quantiles

q
P25 6 2 5
P50 6 2 9
P75 6 7 10


You can specify the optional arguments in either of two ways: by specifying an argument positionally or by specifying a keyword/value pair, as shown in the following statements.

x = T(1:100);
p = do(0.1, 0.9, 0.1);
call qntl(q1, x, p);
call qntl(q2, x) probs=p; /* equivalent */