hi masters,


I just meet a problem which is somewhat frustrated. The survey question always contain some multiple choice questions. Now, the user-written command called "mrtab" works well, but the result is very hard to export to excel, comparing with the table command.

I want to use table command to export multiple question result, mostly the twoway-tablulations. Here is an example below:


Code:
* Example generated by -dataex-. For more info, type help dataex
clear
input double id long(C8__1__1 C8__1__2 C8__1__3 C8__1__4 C8__1__5 C8__1__6 C8__1__7 age)
5981 1 0 0 0 1 1 0 2
2069 1 0 0 0 0 0 0 4
3988 1 0 0 0 0 0 0 2
3766 1 0 0 1 0 0 0 3
 997 1 0 0 0 0 0 0 2
3869 0 1 1 0 0 0 0 2
7296 1 0 0 0 0 0 0 2
8019 1 0 0 0 0 0 0 5
5503 1 0 0 0 0 0 0 2
7734 1 1 0 0 0 0 0 3
 300 1 0 1 0 1 1 0 4
7132 1 0 0 0 0 0 0 3
2393 1 0 0 0 1 1 0 2
3703 1 0 0 0 0 0 0 3
3510 1 1 0 0 0 0 0 2
8531 1 0 0 0 0 0 0 3
8551 1 0 0 0 0 1 0 3
3536 1 1 1 1 0 0 0 2
4255 1 0 0 0 0 0 0 3
3786 1 1 1 0 0 0 0 2
2782 1 1 1 0 0 0 0 3
3052 1 0 1 1 0 0 0 3
2519 0 0 1 0 0 0 0 2
 230 0 0 1 0 0 0 0 1
4195 1 1 1 0 0 0 0 1
7415 1 0 0 0 0 0 0 2
8522 1 0 0 0 0 0 0 3
8503 1 0 1 0 1 0 0 3
4269 1 0 0 0 0 0 0 3
4927 1 0 0 0 0 0 0 3
 969 1 0 0 0 1 0 0 2
9067 1 0 0 0 0 0 0 3
3670 1 0 0 0 0 0 0 3
5774 1 0 0 0 1 0 0 2
7088 1 1 1 0 0 0 0 2
2568 0 0 1 0 0 0 0 4
8619 1 1 0 0 0 0 0 3
9202 1 0 0 0 0 0 0 2
9046 1 0 0 0 0 0 0 3
6165 1 0 0 1 0 0 0 3
 322 1 0 1 0 0 0 0 1
5889 0 0 0 0 1 0 0 3
6483 1 0 0 0 0 0 0 3
2212 1 1 1 1 1 0 0 3
8798 1 0 0 0 0 0 0 3
9021 1 0 0 0 0 0 0 3
8923 1 1 1 1 1 1 0 2
1063 1 0 0 0 0 0 0 2
8242 1 0 0 0 0 0 0 2
6315 1 0 1 0 1 0 0 3
2985 1 0 0 0 0 0 0 1
9127 1 0 0 0 0 0 0 4
9035 1 0 0 0 0 0 0 3
 162 1 0 0 1 0 0 0 2
4148 0 0 0 1 0 0 0 2
5896 1 0 0 0 1 0 0 2
 974 1 0 0 0 0 1 0 2
5571 1 0 0 0 0 0 0 3
1655 1 0 0 0 0 0 0 2
4123 1 0 0 1 0 0 0 3
 924 1 0 0 1 0 0 0 3
8069 1 0 1 0 0 0 0 3
8084 1 0 0 0 0 0 0 2
4801 1 1 1 0 0 0 0 2
7096 1 0 0 0 0 0 0 3
7418 1 0 1 1 0 0 0 3
7940 1 0 0 0 0 0 0 2
9187 1 0 0 0 0 0 0 2
5083 1 0 0 0 0 0 0 3
2403 1 0 0 0 0 0 0 3
3188 1 0 0 0 0 0 0 2
2276 1 0 0 1 0 0 0 3
8247 1 0 0 1 0 1 0 3
3984 1 0 0 0 0 0 0 3
  31 1 0 0 1 0 0 0 2
2806 1 1 0 0 0 0 0 2
6317 1 0 1 0 1 0 0 2
5204 1 0 1 1 1 1 0 3
6226 1 0 0 0 0 0 0 2
8758 1 0 0 1 0 1 0 4
 952 1 0 0 1 0 0 0 4
4634 1 0 0 1 0 1 0 2
8124 1 1 0 0 0 0 0 3
9063 1 0 0 0 0 1 0 3
  27 1 1 1 1 0 0 0 2
 118 1 0 1 1 0 0 0 2
3754 1 0 1 0 0 0 0 3
8844 1 0 0 0 0 0 0 3
3909 1 0 0 1 0 0 0 2
5281 1 0 0 0 0 0 0 4
6627 1 0 0 0 0 0 0 2
6817 1 1 0 0 0 0 0 3
end
label values C8__1__1 C8__1__1
label values C8__1__2 C8__1__2
label values C8__1__3 C8__1__3
label values C8__1__4 C8__1__4
label values C8__1__5 C8__1__5
label values C8__1__6 C8__1__6
label values C8__1__7 C8__1__7
label values age age
label def age 1 "<24years", modify
label def age 2 "25-34years", modify
label def age 3 "35-44years", modify
label def age 4 "45-55years", modify
label def age 5 ">55years", modify

* ssc install mrtab // install mrtab if needed

mrtab C8__1__1-C8__1__7, by(age) rcol nofreq  
_mrsvmat, stat(rcol) rtotal clear nopercent         // the result is what I want, but how to do this by table command?

* ideally, I want a table like this:
table ()(age), stat(mean C8__1__1-C8__1__7) stat(n age) listwise

* but the value of each cell is not correct because I want the percentage is a relative percentage

The most important reason that I do not want to use mrtab is that, it can not use collect commands to manage the tables and combined with other table commands to export to excel.

Anyone has idea to use table command to replicate the result as mrtab?