|
Thomas,
Mark's suggested SQL solution already does what you want. One, non-sql
approach might be:
data foo;
input id $ x1 x2 x3 x4 x5 x6;
datalines;
a 1234 2345 0349 1234 5678 1234
b 7890 0123 7890 7890 . 0123
c 1234 4567 8901 3456 2456 0012
d 0987 8765 3456 . . .
;
run;
proc transpose data=foo out=bar;
by id;
run;
proc sort data=bar nodupkey;
by id col1;
run;
proc means data=bar n nonobs;
class id;
var col1;
output out=temp n=;
run;
data final (drop=_: rename=(col1=count_diff));
merge foo temp;
by id;
if _type_ eq 1;
run;
Art
--------
On Sat, 30 Apr 2005 01:14:10 -0400, Thomas <tythong@YAHOO.COM> wrote:
>May I know how to count the non-missing variables with different numbers
>but treat the same numbers as one count?
>
>*data;
>id x1 x2 x3 x4 x5 x6
>a 1234 2345 0349 1234 5678 1234
>b 7890 0123 7890 7890 . 0123
>c 1234 4567 8901 3456 2456 0012
>d 0987 8765 3456 . . .
>
>*expected;
>id x1 x2 x3 x4 x5 x6 count_diff
>a 1234 2345 0349 1234 5678 1234 4
>b 7890 0123 7890 7890 . 0123 2
>c 1234 4567 8901 3456 2456 0012 6
>d 0987 8765 3456 . . . 3
|