I am trying to add a chi-square test p-value column to my cross-tabulation table. I have already created tables using the collect command for the frequencies but don't know how to do that for chi2 test results.
How to export chi2 p-values from stata to excel when using foreach loop command:
To get my chi2 results I am using a command like this:
foreach v of varlist v1 v2 v3 v4 {
tab `v' group_variable if group_variable!=3, chi2
}
The group_variable is a 3 category variable and I am trying to do a pairwise comparison between group_variable==1 and group_variable==2.
This code works fine and I get all the results correctly, but I want to export all the p values in a table format in excel for all the variables in the loop. Any easy way to do this or any new command line to add here?
How to export chi2 p-values from stata to excel when using foreach loop command:
To get my chi2 results I am using a command like this:
foreach v of varlist v1 v2 v3 v4 {
tab `v' group_variable if group_variable!=3, chi2
}
The group_variable is a 3 category variable and I am trying to do a pairwise comparison between group_variable==1 and group_variable==2.
This code works fine and I get all the results correctly, but I want to export all the p values in a table format in excel for all the variables in the loop. Any easy way to do this or any new command line to add here?
Comment