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 <[email protected]>:
> 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
> [email protected]
>
> 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/