Hi,
I’m having trouble getting the counts of variables in rows by gender.
I want the rows to be: N (total number of women/men), then var1, var2 — listed one after another.
In the columns, at the top, there should be gender (grouping variable), with categories 0 and 1 displayed below the gender label. After that, some statistics.
My biggest problem is showing the counts of each variable in the rows broken down by gender.
Is it possible to do this using table or collect?
I would like to get table like this:
sex | ||
male | female | |
frequency | frequency | |
N | 50 | 60 |
var1 | 20 | 10 |
var2 | 30 | 50 |
Code:
clear input byte(Sex var1 var2) 1 1 1 2 1 0 1 0 1 2 0 0 2 0 1 2 . 0 1 . 1 1 . 1 1 1 1 2 0 0 2 1 0 2 . 1 1 1 0 1 . 1 2 . 1 2 1 1 end tabulate Sex tabulate var1 tabulate var2 table (Sex), statistic(frequency) collect layout (var1 var2) (result)
Comment