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

st: RE: Repeating sets of commands


From   "David Harrison" <David@icnarc.org>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: Repeating sets of commands
Date   Mon, 7 Feb 2005 11:44:26 -0000

The -levels- and -foreach- commands are the way to go...

levels clin_site, local(clin)
foreach c of local clin {
    <command> if clin_site=="`c'"
    etc
}


David
david@icnarc.org

-----Original Message-----
From: Paul O'Brien [mailto:paul.obrien@afe2.org.uk]
Sent: 07 February 2005 11:39
To: statalist@hsphsun2.harvard.edu
Subject: st: Repeating sets of commands


I have a database of clinic visits and want to analyze by clinic site. 
How do I repeat a set of 10 commands for each clinic site (clin_site).

This is a selection of the commands:

table iud ptboro if year_f==2003 & clin_site=="RC", row col
table ltprog ptboro if year_f==2003 & clin_site=="RC", row col
table pt ptboro if year_f==2003 & clin_site=="RC", row col
table cs ptboro if year_f==2003 & clin_site=="RC", row col

.by ...: will repeat the first line and then go onto the next.

I want to run all the commands together for one clinic site (e.g. 
clin_site=="RC") and then repeat for the next value of clin_site.

Thanks

Paul




*
*   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/



*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index