loop problem

For questions regarding programming in the EViews programming language.

Moderators: EViews Gareth, EViews Moderator, EViews Jason, EViews Matt

michi
Posts: 11
Joined: Thu Apr 18, 2013 7:48 am

loop problem

Postby michi » Thu Apr 18, 2013 8:07 am

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!

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13583
Joined: Tue Sep 16, 2008 5:38 pm

Re: loop problem

Postby EViews Gareth » Thu Apr 18, 2013 8:11 am

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


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 2 guests