Data editing > Expressions > Arithmetic expressions > Counting the number of codes in a column
 
Counting the number of codes in a column
Quick reference
To count the number of codes in a column or list of columns, type:
numb(cn1['codes'], cn2['codes'], ... )
If any columns are followed by a code reference, only those codes are counted for those columns.
More information
The function numb is an arithmetic expression which counts the number of codes in a column or list of columns. Its format is:
numb(cn1,cn2, ... cnn)
where cn1 to cnn are the columns whose codes are to be counted. For example, to count the number of codes in columns 132 to 135, type:
numb(c132,c133,c134,c135)
Even though the columns are consecutive, each one is entered separately, with each column number preceded by a ā€˜cā€™. It is incorrect to define only the start and end columns of a field when using numb. Therefore it is wrong to write numb(c(132,135)) or numb(c(132,135)).
Sometimes you might be interested in only certain codes. For example, you might want to know how many 1, 2 or 3 codes there are in a group of columns. In this case, the function is entered as:
numb(cn'p1',cn'p2', ... cnn'pn')
where p1 to pn are the codes to be counted. Only the named codes are counted; any others appearing in the columns are ignored. For example, the data on card 1 might be like this:
1---+----2---...---5----+----4
    1 2 1
    6 / /
    8 6 7
    9
To count the number of codes in column 115 and also the number of codes in the range ā€˜5/8ā€™ in columns 121 and 157, enter this expression:
numb(c115,c121'5/8',c157'5/8')
When Quantum checks these columns and codes, it tells you that there are 9 codes in these columns which are within the given ranges. These codes are all four codes in column 115 (the expression did not specify which codes to count in that column), codes 5 and 6 in column 121 (codes 2 to 4 are outside the given range), and codes 5 to 7 in column 157 (codes 1 to 4 are outside the given range).
See also
Arithmetic expressions