Dear all, I have a panel dataset and I am trying to do simple chi-square tests by sex on about 140 variables. The output I need is the frequency and % of respondents who mentioned each of the 140 variables and the chi square. I am using version 14. I have tried mrtab, tabchi and tabm but these don't give me the respondent level results unless I maybe need to combine these with other commands?
I am using the following commands but getting errors.
***This loop above works fine, however when I add sex and chi I get errors below:
too many variables specified
r(103);
This code with tabchi also works however results are not respondent level....
Looking forward to your responses. Thank you.
I am using the following commands but getting errors.
Code:
. xtset RESPONDENT_ID . foreach var of varlist earlymaturity resistantpestdis resistantwind adaptable { 2. xttab `var' 3. }
Code:
. foreach var of varlist earlymaturity resistantpestdis resistantwind adaptable { 2. xttab `var' sex, chi 3. }
r(103);
This code with tabchi also works however results are not respondent level....
Code:
. foreach var of varlist earlymaturity resistantpestdis resistantwind adaptable { 2. tabchi sex `var' 3. }
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input int RESPONDENT_ID long sex byte(earlymaturity resistantpestdis resistantwind adaptable) 1 3 0 0 0 0 1 3 0 0 0 0 1 3 0 1 0 0 2 2 0 0 0 0 2 2 0 0 0 0 3 3 0 0 0 0 3 3 0 0 0 0 3 3 0 0 0 0 3 3 0 0 0 0 4 3 0 0 0 0 4 3 0 0 0 0 4 3 0 1 0 0 4 3 0 0 0 0 4 3 0 0 0 0 4 3 0 1 0 0 4 3 0 0 0 0 4 3 0 0 0 0 5 2 0 0 1 0 5 2 0 1 0 0 5 2 0 0 0 0 6 3 0 0 0 0 6 3 0 0 0 0 6 3 0 0 0 0 6 3 1 0 0 0 7 2 0 0 0 0 7 2 0 0 0 0 7 2 0 0 0 0 7 2 0 1 0 0 8 3 0 0 0 0 8 3 1 0 0 0 8 3 0 0 0 0 8 3 0 0 0 0 8 3 0 0 0 0 8 3 0 0 0 0 8 3 1 0 0 0 8 3 0 0 0 0 8 3 0 0 0 0 8 3 0 0 0 0 8 3 0 0 0 0 8 3 1 0 0 0 9 2 0 0 0 0 9 2 0 0 0 0 9 2 0 0 0 0 10 3 0 0 0 0 10 3 0 0 0 0 10 3 0 0 0 0 10 3 0 0 0 0 12 3 0 0 0 0 12 3 1 0 0 0 12 3 0 0 0 0 13 2 0 0 0 0 13 2 0 0 0 0 13 2 0 0 0 0 13 2 0 0 0 0 13 2 1 0 0 0 14 3 0 0 0 0 14 3 0 0 0 0 14 3 0 0 0 0 15 2 0 0 0 0 16 3 0 0 0 0 16 3 0 0 0 0 16 3 0 0 0 0 16 3 0 0 0 0 16 3 0 1 0 0 16 3 0 0 0 0 17 2 0 0 0 0 17 2 0 0 0 0 17 2 0 0 0 0 17 2 0 0 0 0 17 2 0 0 0 0 17 2 0 0 0 0 18 3 1 0 0 0 18 3 0 0 0 0 18 3 0 0 0 0 18 3 1 0 1 1 18 3 1 0 0 0 18 3 1 0 0 0 18 3 1 1 0 0 18 3 0 1 0 0 18 3 0 1 0 0 18 3 0 0 0 0 19 2 0 0 0 0 19 2 0 0 0 0 19 2 0 0 0 0 19 2 1 0 0 0 20 2 0 0 0 0 20 2 1 0 0 0 20 2 0 0 0 0 20 2 0 0 0 0 21 3 0 0 0 0 21 3 0 0 0 0 21 3 0 0 0 0 21 3 0 0 0 0 21 3 0 0 0 0 21 3 0 0 0 0 21 3 0 0 0 0 21 3 0 0 0 0 21 3 0 0 0 0 21 3 0 0 0 0 22 3 0 0 0 0 end label values sex sex label def sex 2 "female", modify label def sex 3 "male", modify
Comment