Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: re: why aren't commands displayed within a foreach-loop


From   Kit Baum <[email protected]>
To   [email protected]
Subject   st: re: why aren't commands displayed within a foreach-loop
Date   Tue, 20 Nov 2007 23:06:41 -0500

If you run this from a do-file you will see:

. foreach x in "mpg" "price" {
2. ttest `x', by(foreign)
3. }

The commands you have given are echoed. Their invocations multiple times are not. Easy enough to get the display:

sysuse auto, clear
foreach x in "mpg" "price" {
di _n "T-test for `x'"
ttest `x', by(foreign)
}

This will label each test with the variable being tested. You could add any additional information in that display statement.

Kit

Kit Baum, Boston College Economics and DIW Berlin
http://ideas.repec.org/e/pba1.html
An Introduction to Modern Econometrics Using Stata:
http://www.stata-press.com/books/imeus.html


*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/




© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index