MODEpossible in proc sqlwith subquery.
data have;
call streaminit(7);
do id = 1 to 100;
x = rand('Geometric',.2);
output;
end;
run;
proc sql;
select x as mode from (
select x, count(1) as count from have group by x
)
having count=max(count);
quit;
This allows you to use automatic SAS reuse for you; if you want to avoid this, you need to work a bit to have instructions for work.
You may still need further work on this, as you may have several modes, and this does not distinguish them (it returns all modes).
source
share