COUNTN Function

COUNTN( x <, method> ) ;

The COUNTN function counts the number of nonmissing values in a matrix. The arguments are as follows:

x

specifies an numerical or character matrix. The COUNTN function counts the number of nonmissing values in this matrix.

method

specifies the method used to count the nonmissing values. This argument is optional. The following are valid values:

"all"

specifies that all nonmissing values are counted. This is the default value. The function returns a matrix.

"row"

specifies that the function return an matrix whose th element is the number of nonmissing values in the th row of x.

"col"

specifies that the function return a matrix whose th element is the number of nonmissing values in the th row of x.

The method argument is not case-sensitive. The first three characters are used to determine the value.

For example, the following statements count nonmissing values for a matrix x:

x = {1 2 3,
     . 0 2, 
     1 . .,
     1 0 . };
totalN = countn(x);
rowN = countn(x, "ROW");
colN = countn(x, "COL");
print totalN, rowN, colN;

Figure 23.71 Counts of Nonmissing Values
totalN
8

rowN
3
2
1
2

colN
3 3 2