Hi,
I currently have a foreach loop which exports p-values from chi-squared tests into excel:
I was considering using 4 if statements, describing that for any combination between yes and no for exposure1 and `v', the box would be replaced with r(p_exact).
Any advice on how this can be expressed is greatly appreciated!
Priscilla
I currently have a foreach loop which exports p-values from chi-squared tests into excel:
I am hoping to incorporate an if statement, so that r(p_exact) is displayed instead of r(p) when any box in my tabulation 2 by 2 table is less than 5; however, I'm not quite sure how the if conditions should be written.
putexcel set "C:\Users\priscilla\stataexport", sheet("p-values") modify
scalar k = 5
foreach v of varlist char1 char2{
tabulate exposure1 `v' if cond1!=. & cond2!=., chi2 exact row col
putexcel D`=k' = `r(p)'
*insert code described below here
scalar k = k + 1
}
I was considering using 4 if statements, describing that for any combination between yes and no for exposure1 and `v', the box would be replaced with r(p_exact).
Any advice on how this can be expressed is greatly appreciated!
Priscilla