Page 1 of 1

loop problem

Posted: Thu Apr 18, 2013 8:07 am
by michi
Hi everybody,

i'm using eviews 7 and have a problem with the following.
I need to create an alpha object land_abk that contains the values A, B, ..., J. One alpha object land_name that contains the values "Republik A", "Republik B", ... , "Republik J". And one series object d_member containing the value 0 for the first 5 observations and 1 for the last 5 observations.

I got the right answer, but I'm not sure if I really understand what I am doing there.

pagecreate(page=land) u 10
alpha land_abk
alpha land_name
series d_member=0
d_member.setformat f.0
!i = 1
for %ctr A B C D E F G H I J
smpl !i !i
land_abk = %ctr
land_name = "Republik "+%ctr
if !i > 5 then
d_member = 1
endif
!i =!i + 1
next
sample@all

I have difficulties with the FOR loop. Generally I understand what to do, but what does that "smpl !i !i" (= smpl 1 1?) and that "!i = !i+1" mean?

thanks for your help!

Re: loop problem

Posted: Thu Apr 18, 2013 8:11 am
by EViews Gareth

Code: Select all

smpl 1 1
sets the sample to be only the first observation. Anything you subsequently do with a series or an alpha will only happen to the first observation of that series or alpha.

The next time through the loop it switches to the second observation. And so on...