Hello @mt88,
@ballardw wrote:
And here is an example where the result is incorrect for two-digit value
data test;
input a b c d;
Numzero = count(cats(a,b,c,d),'11');
cards;
1 0 9 1
1 1 0 0
0 9 11 1
0 0 9 1
;
run;
The incorrect result for line 1 is because the CATS result for the line looks like "1100" and so there are two 1's next to each other and the Count function treats them as such.
This problem can be avoided by introducing a delimiter:
data want;
set test;
newvar=count(catx('||',.,of a--d,.),'|0|');
run;
(where 0 could be replaced by 11 or any other number whose character representation is to be counted -- or even by a non-numeric character string).
... View more