UNIQUE picks all unique values, and COUNTUNIQUE counts the number of the unique values. For example,
proc iml;
call randseed(1);
x=randfun(5000,"poi",1000);
ux=unique(x);
cux=countunique(x);
quit;
This code simulates X~Poisson(1000) 5000 times. There are 187 unique values from 889 to 1108. Is there any efficient way to get the number of observations for each unique value? For example, 47 out of 5000 observations are X=1000. I use
do i=1 to cux;
if i=1 then n=sum(x=ux[i]);
else n=n||sum(x=ux[i]);
end;
but am looking for a better one.