Hi, I have a dataset where I am trying to tabulate two variables against each-other in chi2 tests, but I need to tabulate them by group and then store the p value for each group. I've tried using:
but it just creates a variable called "result_group" with the p value for a chi2 across the entire dataset, but I want a chi2 p value for each test of x and y in a group
Code:
foreach x in group { tab x y if group == `x', chi2 gen result_`x' = r(p) if group == `x' }
Comment