After transposing you could also use proc summary:
proc summary data=long nway;
class Col1;
output out=work.counted(drop= _type_ rename=(_freq_=Count));
run;
Or, if you love to write unnecessary long programs, use a hash-object:
data _null_;
set have end=jobDone;
length Code Count 8;
array codes[3] Code1-Code3;
if _n_ = 1 then do;
declare hash h(ordered: 'yes');
h.defineKey('Code');
h.defineData('Code', 'Count');
h.defineDone();
end;
do i = 1 to dim(codes);
if not missing(codes[i]) then do;
Code = codes[i];
if h.find() = 0 then do;
Count = Count + 1;
h.replace();
end;
else do;
Count = 1;
h.add();
end;
end;
end;
if jobDone then do;
h.output(dataset: 'work.hashCount');
end;
run;
... View more