Hi JohnI,
I'm not sure what you mean by simple, but something like this might help:
data have;
input id var1 var2 var3 var4 var5;
cards;
1 1 2 3 4 5
2 1 2 2 3 4
3 3 3 2 1 3
4 4 1 2 3 1
;
run;
data want(keep=id var1--var5 n distinct);
set have;
array v_(*) var1--var5;
array _dist_(10) _temporary_;
do j = 1 to 10;
_dist_(j) = .;
end;
do i = 1 to dim(v_);
_dist_(v_(i)) = 1;
end;
distinct = 0;
do j = 1 to 10;
if _dist_(j) ne . then distinct = distinct + 1;
end;
n = n(of var1--var5);
run;
I've only used five variables and a limit of 10 for the value, but you could extend this for n variables and a wide range of integer values.
Robert