Hi,
I'm trying to export a table of two-sided p-values generated from two-sample t tests for about two dozen variables and three groups. Let's say I have variables a, b, c, and d, and groups 1, 2, and 3. For each variable, I'd like to conduct two-sample t tests for all pairwise combinations of the groups. Here is code to do this:
I'd then like to save the two-sided p-value from each test and put it into a table where each column is a different pairwise combination (i.e. 1-2, 1-3, and 2-3) and each row is a different variable. The values in the table would be the p-values. Using esttab, I'd like to export this table into .tex format. I don't have code to show for either saving the p-values or exporting the table as I've tried a few different things using eststo, estpost, and estadd, but thus far none have worked.
I know that the command ttest stores the estimation results and I will need to use r(p), but I'm unsure of how to put it into either a local or a new variable that takes on a different value depending on the pairwise combination.
I'm using Stata 15.1. Any help would be greatly appreciated. I haven't posted on statalist many times before so apologies if there are any posting rules I missed.
Thanks,
Keanan
I'm trying to export a table of two-sided p-values generated from two-sample t tests for about two dozen variables and three groups. Let's say I have variables a, b, c, and d, and groups 1, 2, and 3. For each variable, I'd like to conduct two-sample t tests for all pairwise combinations of the groups. Here is code to do this:
Code:
foreach group in 1 2 3 { foreach var in a b c { ttest `var', by(`group') } }
I know that the command ttest stores the estimation results and I will need to use r(p), but I'm unsure of how to put it into either a local or a new variable that takes on a different value depending on the pairwise combination.
I'm using Stata 15.1. Any help would be greatly appreciated. I haven't posted on statalist many times before so apologies if there are any posting rules I missed.
Thanks,
Keanan
Comment