Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: RE: nested forvalues loop


From   "Martin Weiss" <martin.weiss1@gmx.de>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: nested forvalues loop
Date   Fri, 2 Oct 2009 19:25:53 +0200

<>

You may also want to look at the -recursive- option to - help rolling-...




HTH
Martin


-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Ariel Linden
Sent: Freitag, 2. Oktober 2009 19:10
To: statalist@hsphsun2.harvard.edu
Subject: st: nested forvalues loop

Hi Fellow Stata Users,

I have a basic question about structuring this nested forvalues loop (Stata
v10.1).

I have a panel data set and I want to focus on months 13 thru 24. In each
loop I want to use the lagged values for all the prior months. So I have `i'
which loops through the months 13 thru 24, and `j' that is intended to
increase the lag at each iteration.

For example month 14 should have 0/1 lag and month 24 should have 0/10 lags.


I would appreciate feedback as to if I wrote this correctly. 


forvalues i=14/24 {

	forvalues j=1/10 {

capture logit  Y l(0/`j').X1 l(0/`j').X2 l(0/`j').X3 month if month==`i'

predict ps`i' if month == `i'
}
}

Thanks in advance

Ariel

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