Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, is already up and running.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: Produce a list of two-sided p-values of all t-tests in a loop

From   "Jean-Marie Meier" <>
Subject   st: Produce a list of two-sided p-values of all t-tests in a loop
Date   Mon, 9 May 2011 00:16:48 +0200 (CEST)

Dear Stata list users,

for my data set I want create several tables with descriptive statistics. For these tables I want to test whether the mean and median value of variables are different from 0.
I run the t-tests with the following loop. I now want that Stata produces a list of the two-sided p-values of all t-tests in the loop. the two sided p-value is saved as r(p) if the command ttest is used.
Thus it should be possible to add a command to the loop, that the two-sided p-value is saved each time with a different name (such that not only one p-value is saved, which is constantly overwritten).
However I do not know how to do that! It would be great if someone could help me.

local j=0
global global_name var1 var2 var3 ...

foreach x in $global_name {

local j=`j'+1

ttest `x' == 0


Kind regards,

Jean-Marie Meier
*   For searches and help try:

© Copyright 1996–2016 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index