Page 1 of 1
Creating loop for loading pages
Posted: Fri Dec 12, 2014 1:51 pm
by salahaddin
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
Re: Creating loop for loading pages
Posted: Fri Dec 12, 2014 3:23 pm
by EViews Gareth
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.
Re: Creating loop for loading pages
Posted: Fri Dec 12, 2014 3:52 pm
by salahaddin
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
Re: Creating loop for loading pages
Posted: Fri Dec 12, 2014 4:10 pm
by EViews Gareth
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
Re: Creating loop for loading pages
Posted: Fri Dec 12, 2014 4:49 pm
by salahaddin
Thanks Gareth,
u saved my time. U r Gareth Great:)
Thanks,
Sam