Previous Page | Next Page

Language Reference

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 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 is used, resulting in the quartiles of the data.

method

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

The following are valid options:

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 matrix, the QNTL subroutine computes a matrix where is the dimension of the PROBS= option. 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 23.199 Quantiles
Test of NLPHQN subroutine: No Derivatives

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 23.200 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 */
Previous Page | Next Page | Top of Page