I have used -egen, sum(1)- myself in examples, but it also
involves Stata interpreting about 100 lines, when one
will do the same job:
bysort a b c : gen tabcount = _N
On the original problem, I would suggest
egen group = group(a b c), label
tabstat n, by(group) stat(N sum)
for interactive use. For a program, given that
properly labelled output is essential for
the problem, I would probably use the same -egen-
call, a few -generate-s and a -tabdisp- for the display.
Start with your dataset. Choose the variables you want to keep, suppose
these are variables a, b and c
. bysort a b c: egen tabulation = sum(1)
. duplicates drop
Then you should have the below table as your new dataset.
Here's a simple example program that will simply output the data. If
you're going to use this frequently, save it as tabNway.ado and put it
in your adopath.
program define tabNway
preserve
keep `*'
sort`*'
by `*': egen tabcount = sum(1)
duplicates drop
list
restore
end
In your case you would use input 'tabNway a b c'. I didn't use a tempvar
because that gives a meaningless heading in the list. To get your other
heading you can edit the program.