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

st: Re: Two "forvalues" loops working together


From   jean ries <ries@ires.ucl.ac.be>
To   statalist@hsphsun2.harvard.edu
Subject   st: Re: Two "forvalues" loops working together
Date   Fri, 14 May 2004 10:21:24 +0200

Dear Amani,
Here is a suggestion. Hope it helps.
best regards,
jean

local X 43

forvalues Y = 120(10)530 {
                predict prob`Y', pr0(`Y',`Y+10')
                predict exp`Y', e0(`Y',`Y+10')
                replace prob=prob`Y' in `samp-`X''
                replace exp=exp`Y' in `samp-`X''
                loc X = `X' - 1
}

At 09:47 14/05/2004, you wrote:
Dear Stata-listers,

I wish to make two "forvalues" loops work together rather than nested as
shown by my suggested code below.  Is there a way I can do that in STATA


local samp=_N+43
set obs `samp'
foreach M of newlist prob exp {
        gen `M'=.
}
intreg ptiming timing if ~npointer1, noskip intreg
forvalues Y = 120(10)530 ;  X = 43(-1)1 {
                predict prob`Y', pr0(`Y',`Y+10')
                predict exp`Y', e0(`Y',`Y+10')
                replace prob=prob`Y' in `samp-`X''
                replace exp=exp`Y' in `samp-`X''
}
local samp=_N-43
slist prob exp in `samp'/l

Many thanks for your help in advance.


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