In reply to Richard Montes.

Define and call the following function:

/* alternate approach */
start MyTabulate(levels, freq, x);
levels = unique(x);
freq = j(1, ncol(levels));
do i = 1 to ncol(levels);
freq[i] = sum(x = levels[i]);
end;
finish;