I am using Stata 14 and I have an individual-level dataset.
I have a question about crosstabulation of multiple variables.
I have a list of categorical variables, all with the same three categories. What I would like to do is to create a simple crosstabulation with these variables and a Group variable.
Here is an example of the data.
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input double ID float(Var1 Var2 Var3 Var4 Var5 Var6 Var7) double Group 11729 1 0 0 0 0 1 0 0 11730 2 0 0 0 1 0 0 0 11732 1 1 0 0 0 0 0 0 11733 0 0 0 0 0 1 0 0 11734 1 0 0 0 1 0 0 0 11736 2 0 0 0 1 0 0 0 11737 1 1 0 0 0 0 0 0 11740 0 1 0 0 1 1 0 0 11742 1 0 0 0 1 0 0 0 11743 0 2 0 0 2 0 1 0 11744 1 0 0 0 0 0 0 0 11749 0 1 0 0 1 0 0 0 11751 1 0 0 0 2 1 0 0 11752 0 0 0 0 1 1 0 0 11756 0 1 0 0 0 0 0 0 11760 1 0 0 0 1 0 0 0 11761 1 0 0 0 1 0 0 0 11768 0 0 0 0 1 0 0 0 11772 1 1 0 0 2 0 0 0 11773 1 0 0 0 0 0 0 0 11779 1 0 0 0 2 0 0 0 11782 1 0 0 0 0 0 0 0 11783 1 0 0 0 1 0 0 0 12001 0 0 0 0 0 0 1 1 12003 1 0 0 0 1 0 0 1 12004 0 1 0 0 0 0 1 1 12005 . . . . . . . 1 12007 2 0 0 0 2 2 0 1 12008 2 0 0 0 2 0 0 1 12009 2 0 0 0 2 0 0 1 12010 0 2 0 0 2 0 1 1 12011 0 1 0 0 1 0 0 1 12012 1 0 0 0 2 0 0 1 12014 1 0 2 0 1 0 0 1 12016 1 0 0 0 0 0 0 1 12017 0 1 0 0 2 1 0 1 12020 1 0 1 0 1 0 0 1 12021 1 0 0 0 1 0 0 1 12022 2 0 0 0 0 0 0 1 12023 1 0 0 0 1 0 0 1 12024 1 0 0 0 1 0 0 1 12025 2 2 0 0 0 0 0 1 12026 2 0 0 0 2 0 0 1 12027 2 0 0 0 2 2 0 1 12028 2 0 0 0 2 0 0 1 12029 0 1 0 1 0 1 0 1 12030 1 0 0 0 1 0 0 1 12032 1 0 0 0 1 0 0 1 12033 1 0 2 0 1 1 0 1 12034 1 0 0 0 1 1 0 1 12036 1 0 0 0 0 0 0 1 end
I tried tabm
Code:
tabm Var1-Var7
Code:
tab Var1 Group, col
Group 1 | Total | Group 2 | Total | |||||
Category 1 | Category 2 | Category 3 | Category 1 | Category 2 | Category 3 | |||
Var1 | ||||||||
Var2 | ||||||||
Var3 | ||||||||
Var4 | ||||||||
Var5 | ||||||||
Var6 | ||||||||
Var7 |
I appreciate any suggestion.
0 Response to how to do crosstabulation for a list of variables
Post a Comment