/*
You could set "NA" be missing before counting it.
*/
data have;
input ID ( Fruit Color Vehicle ) ($) Year;
cards;
1 Apple Blue Car 2001
1 Apple NA Car 2001
2 Banana Red Van 2000
2 Banana Blue Car 2000
;
data have;
set have;
array x{*} $ _character_;
do i=1 to dim(x);
if x{i}="NA" then call missing(x{i});
end;
drop i;
run;
proc transpose data=have(obs=0) out=temp;
var _all_;
run;
proc sql noprint;
select cat('count(distinct ',_name_,') as ',_name_) into :count separated by ' ,' from temp;
create table temp2 as
select id as _id,&count. from have group by id;
quit;
proc transpose data=temp2 out=want(where=(col1 ne 1));
by _id;
run;
... View more