Creating loop for loading pages

For questions regarding programming in the EViews programming language.

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

salahaddin
Posts: 17
Joined: Thu Dec 11, 2014 7:11 am

Creating loop for loading pages

Postby salahaddin » Fri Dec 12, 2014 1:51 pm

Hello everyone,
My data is splitted into many parts and I want to put them together by using an Eviews program. You can see the list of the names of the data files. I tried to use the following command:

for !i=01 to 10
for !j=03 to 12
pageload "D:\data\Call{!i}{!j}.xpt"
next
next

However, it didnot work. Could you please provide a command for that?Thanks in advance.

Sam
Attachments
1.jpg
1.jpg (54.29 KiB) Viewed 6462 times

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

Re: Creating loop for loading pages

Postby EViews Gareth » Fri Dec 12, 2014 3:23 pm

In your case, since you have no spaces, simply try:

Code: Select all

for !i=01 to 10 for !j=03 to 12 pageload D:\data\Call{!i}{!j}.xpt next next
The more general solution is:

Code: Select all

for !i=01 to 10 for !j=03 to 12 %file = "d:\data\call" + @str(!i) + @str(!j) + ".xpt" pageload %file next next

As an aside, when requesting help, especially with programming, providing precise error messages or details on the results of code rather than "it didn't work" is beneficial. It is hard for someone to help correct a bug if they don't know exactly what the bug is.

salahaddin
Posts: 17
Joined: Thu Dec 11, 2014 7:11 am

Re: Creating loop for loading pages

Postby salahaddin » Fri Dec 12, 2014 3:52 pm

Thanks Gareth for the help.

However, I got an error shown in the attachment. I think eviews reads "01" as "1" thus instead of "Call0103" eviews tries to find "Call13".

Please help.

Thanks in advance,
Sam
Attachments
11.jpg
11.jpg (20.95 KiB) Viewed 6439 times

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

Re: Creating loop for loading pages

Postby EViews Gareth » Fri Dec 12, 2014 4:10 pm

Code: Select all

for !i=01 to 10 for !j=03 to 12 %i = @str(!i, "i02") %j = @str(!j, "i02") %file = "d:\data\call" + %i + %j + ".xpt" pageload %file next next

salahaddin
Posts: 17
Joined: Thu Dec 11, 2014 7:11 am

Re: Creating loop for loading pages

Postby salahaddin » Fri Dec 12, 2014 4:49 pm

Thanks Gareth,

u saved my time. U r Gareth Great:)

Thanks,
Sam


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 2 guests