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

Re: st: RE: looping when i jumps


From   Rashmi Shankar <rashmi@brandeis.edu>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: RE: looping when i jumps
Date   Tue, 28 Jun 2005 10:09:16 -0400

Hi, Nick: This worked last night when I tried it with a unit root test. But
when I run the following loop, it doesn't work. The problem is that the
dependent variable, bp_level, skips over some of my 56 countries. The loop
stops everytime it hits a country with no bp_level data.


set more off
tsset cnum obs_number , format(%tq)

gen dbp_level = bp_level-bp_level[_n-1]
local vari  "lnpetrol lnchinaimp"
foreach y of num 1/56 {
foreach x of local vari {
disp `y'
dfuller `x' if cnum==`y' , trend lags(4) regress
}
}

**1st differenced
foreach y of num 1/56 {
foreach x of local vari {
gen d`x' = `x'-`x'[_n-1]
disp `y'
dfuller d`x' if cnum==`y' , trend lags(4) regress
drop d`x'
}
}
Quoting Nick Cox <n.j.cox@durham.ac.uk>:

> Yes.
>
> http://www.stata.com/support/faqs/data/foreach.html
>
> may help. If not, you will need to tell us more
> about your problem to get much better advice.
>
> Nick
> n.j.cox@durham.ac.uk
>
> Rashmi Shankar
>
> > Is it possible to run a loop when the series indexed to i
> > jumps (for example goes from i=1 to i=7)?
>
> *
> *   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/
>


-- 
Rashmi Shankar
Asst. Professor, Department of Economics,
Brandeis International Business School
Brandeis University,
415 South Street,
Waltham, MA 02454
Phone: 781-736-2265
Fax: 781-736-2269
*
*   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