Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: writing output with -file- command

From   Richard Aplenc <>
Subject   st: writing output with -file- command
Date   Tue, 17 Dec 2002 12:25:38 -0500

I would like to write the output of a nested -foreach- loop to a .txt
file with the -file- command, and am having some difficulty doing so successfully.

My dataset consists of patients with length of chemotherapy courses and variables for gender, race, and treatment, all of which are binary variables. I would like to be able to compare length of chemotherapy course by sex, race, and treatment and output the mean, sd, and p value for each comparison.

I would appreciate help in using the -file- command to output these values to a .txt file.

My code is as follows:

local variables "sex race treatment"
local courses "course100 course200 course300 course701 course702

foreach course of local courses {
foreach variable of local variables {
ttest `course', by(`variable')

Thanks in advance for the help and my apologies for not being able to figure this out on my own.


Richard Aplenc, MD
Pediatric Oncology/Stem Cell Transplant
Children's Hospital of Philadelphia
Center for Clinical Epidemiology and Biostatistics
University of Pennsylvania
215-573-0259 (lab)
215-590-4183 (fax)

* For searches and help try:

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