Syntax Supported by the IML Procedure and the iml Action
COUNTN Function
COUNTN (x <, method> ) ;
This function is supported by the IML procedure and the iml action.
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 ith element is the number of nonmissing values in the ith row of x.
- "col"
specifies that the function return a
matrix whose jth element is the number of nonmissing values in the jth 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 47: Counts of Nonmissing Values
| totalN |
|---|
| 8 |
| rowN |
|---|
| 3 |
| 2 |
| 1 |
| 2 |
| colN | ||
|---|---|---|
| 3 | 3 | 2 |