Is it possible to do a loop that executes a regression for each of the variables in a workfile that begin with a specific string of characters? In the below code I am trying to run a regression for each of the dependent variables that starts with "key", i.e. Key1 Key2, Key3, etc.
I could write out the dependent variables but unfortunately this vector changes each time.
for %0 Key*
equation eq_{%0}.ls c A B
forecast {%0}f
next
Is there some other way to perform this loop? EViews does not allow the wildcard expression (*) to be used since it is an illegal or reserved name.
Thanks!
PacNW
For Loop of Regressions using a wild card
Moderators: EViews Gareth, EViews Moderator, EViews Jason, EViews Matt
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13603
- Joined: Tue Sep 16, 2008 5:38 pm
Re: For Loop of Regressions using a wild card
Code: Select all
%deplist = @wlookup("key*", "series") 'create a list of all series that match the pattern key*
for %dep %deplist 'cycle through the members of the list one at a time.
equation eq_{%dep}.ls {%dep} c a b
next
Re: For Loop of Regressions using a wild card
Thanks for the quick reply!
I tried your code and I get a Syntax Error message at the "For" line
I tried your code and I get a Syntax Error message at the "For" line
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13603
- Joined: Tue Sep 16, 2008 5:38 pm
Re: For Loop of Regressions using a wild card
My bad:
Code: Select all
%deplist = @wlookup("key*", "series") 'create a list of all series that match the pattern key*
for %dep {%deplist} 'cycle through the members of the list one at a time.
equation eq_{%dep}.ls {%dep} c a b
next
Re: For Loop of Regressions using a wild card
worked like a charm, thank you
Re: For Loop of Regressions using a wild card
I might be reaching here, but I'll give it a shot...
How would I change the code you posted...
%deplist = @wlookup("key*", "series") 'create a list of all series that match the pattern key*
for %dep {%deplist} 'cycle through the members of the list one at a time.
equation eq_{%dep}.ls {%dep} c a b
next
...if I wanted to repeat the process for another set of variables, in addition to "key"? So run the exact same process for "minor*". (Of course I could simply post a new set of code below it, but I'm really asking how to do it for 20 other sets of variables in a giant loop)
I tried a series of nested brackets but could not get it to execute.
Thanks!
How would I change the code you posted...
%deplist = @wlookup("key*", "series") 'create a list of all series that match the pattern key*
for %dep {%deplist} 'cycle through the members of the list one at a time.
equation eq_{%dep}.ls {%dep} c a b
next
...if I wanted to repeat the process for another set of variables, in addition to "key"? So run the exact same process for "minor*". (Of course I could simply post a new set of code below it, but I'm really asking how to do it for 20 other sets of variables in a giant loop)
I tried a series of nested brackets but could not get it to execute.
Thanks!
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13603
- Joined: Tue Sep 16, 2008 5:38 pm
For Loop of Regressions using a wild card
Code: Select all
%keylist = @wlookup("key*", "series")
%minorlist = @wlookup("minor*", "series")
For %dep {%keylist} {%minorlist}
'same stuff here
Re: For Loop of Regressions using a wild card
Excellent.
Sending code from a phone... whatever you get paid, they should double it.
Sending code from a phone... whatever you get paid, they should double it.
-
EViews Glenn
- EViews Developer
- Posts: 2682
- Joined: Wed Oct 15, 2008 9:17 am
Re: For Loop of Regressions using a wild card
Not really. We only let him work from a phone. No computer. He can't get into as much trouble that way.

Who is online
Users browsing this forum: No registered users and 2 guests
