Useful to know about these count functions - thanks. The IML example reminds me of a situation where I have been burnt before. Above I would have coded loc(rowMiss) rather than loc(rowMiss>0), it makes no difference in your example (apart from a little faster run time!). But once I had a bug in a program that was due to coding loc(x^=0), eventually I realised that the x^=0 part is not only redundant, but it also throws away the masking of missing values that is built into plain loc(x).