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

RE: st: RE: looping when i jumps


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   RE: st: RE: looping when i jumps
Date   Tue, 28 Jun 2005 18:16:03 +0100

The FAQ cited discusses precisely this problem. 
Please do read it. 

Nick 
n.j.cox@durham.ac.uk 

Rashmi Shankar
 
> 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.
> >

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