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

Re: st: display commands generated within foreach-loop

From   "Svend Juul" <SJ@SOCI.AU.DK>
To   <>
Subject   Re: st: display commands generated within foreach-loop
Date   Tue, 20 Nov 2007 11:28:10 +0100

Thorsten wrote:
I'm sure my problem has a real simple solution, but 
I am unable to find it - how can I actually *see* 
the commands generated by a foreach-loop.
Let's say I have the following:
sysuse auto, clear
foreach x in "mpg" "price" {
ttest `x', by(foreign)

In this case, I would like to see
ttest mpg, by(foreign)
... output ...
ttest price, by(foreign)
... output ...
in my logfile, but I don't. All I see is the output of the T-test.
- and Maarten gave useful advice.
However, I think that Thorstens problem illustrates a
design problem with the -ttest- output; the names
of the variables involved ought to be included in the
At least some other commands do that, e.g.:
     foreach x of varlist mpg price {
        tab1 `x'
-tab1- does it right. But -tabulate- is not satisfactory,
it only displays the sometimes ambiguous variable label, not 
the unambiguous variable name.
     foreach x of varlist mpg price {
        tabulate `x'
This was for the wishlist: Some af Stata's basics are still

Svend Juul
Institut for Folkesundhed, Afdeling for Epidemiologi
(Institute of Public Health, Department of Epidemiology)
Vennelyst Boulevard 6 
DK-8000 Aarhus C,  Denmark 
Phone, work:  +45 8942 6090 
Phone, home:  +45 8693 7796 
Fax:          +45 8613 1580 

*   For searches and help try:

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