Statalist


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

Re: st: if ... the lot of them


From   "Eva Poen" <[email protected]>
To   [email protected]
Subject   Re: st: if ... the lot of them
Date   Mon, 29 Sep 2008 21:28:58 +0100

How about, at the beginning of your do-file:

local iff "duration==1 & num==1"

...

list r1 se1 r2 se2 if `iff' & outcome=="pregnancy"

etc., which means you have to change duration only in one line.

Or, you can do a loop and do it for many different levels of duration
at the same time:

foreach d of numlist 1 2 4 6/11 {
 list r1 se1 r2 se2 if duration==`d' & outcome =="pregnancy" &num==1
... if duration==`d'
}

Or you could write yourself a little program/do-file that takes
duration as an argument.  But do not confuse the if qualifier with the
-if- programming command:
http://www.stata.com/support/faqs/lang/ifqualifier.html


Hope this helps.



2008/9/29 Paul O'Brien <[email protected]>:
> i have a sequence of commands, each of which has included: duration==1.
>
> such as:
> list r1 se1 r2 se2 if duration==1 & outcome =="pregnancy" &num==1
> metan logrr selogrr if num==1 &outcome=="pregnancy" &duration==1, fixed
> eform nograph
> swapval iud1 iud2 if duration=1 &num==1
> ...
>
> i need to change the duration frequently and have to change all the commands
> each time.
>
> is there a way to put all the commands together so i can change the duration
> just once every time i run the sequence?
>
> i have looked at foreach and forvalues.
>
> thanks
>
> -------------------------------
> Dr Paul O'Brien
> Raymede Clinic
> Westside Contraceptive Services
> Westminster Primary Care Trust
> Exmoor St
> London
> W10 6DZ
> UK
> 44 + (0)20 8962 4450
>
>
>
>
>
>
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/statalist/faq
> *   http://www.ats.ucla.edu/stat/stata/
>
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   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