Hello, I want to apply certain procedures to all variables in my data set.
So I want to loop over all variables in my dataset.
How should I build the loop?
How can I evoque all variables?
One possible way is to store all variable names into a string using "names=@wlookup("*","series")" and then build the loop over the string "names". Am I right?
How can I do that?
Thank you.
B.
Loop over all variables
Moderators: EViews Gareth, EViews Moderator, EViews Jason, EViews Matt
Loop over all variables
Last edited by bdamasio on Thu Nov 05, 2015 8:59 am, edited 1 time in total.
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13583
- Joined: Tue Sep 16, 2008 5:38 pm
Re: Loop over all variables
Either create a group containing all series:
and loop through the members of the group, or use the @wlookup function to retrieve the names of every series in the workfile and loop through them.
Either way, remember that RESID is a series in your workfile, and you probably don't want to do whatever you're doing to RESID.
Code: Select all
group g *
Either way, remember that RESID is a series in your workfile, and you probably don't want to do whatever you're doing to RESID.
Re: Loop over all variables
Hi everyone,
I have series as independent variables x1,x2...x150 and I want to create the log of these series. Does anyone know if there is any other efficient way instead of doing it manually (meaning, to write for every single variable log_xi=log(xi), for i=1,2..150)? Is it possible to keep the name of the variable as it is and just add a term for example log_x1,log_x2...log_x150.
Thank you very much, in advance.
I have series as independent variables x1,x2...x150 and I want to create the log of these series. Does anyone know if there is any other efficient way instead of doing it manually (meaning, to write for every single variable log_xi=log(xi), for i=1,2..150)? Is it possible to keep the name of the variable as it is and just add a term for example log_x1,log_x2...log_x150.
Thank you very much, in advance.
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13583
- Joined: Tue Sep 16, 2008 5:38 pm
Re: Loop over all variables
Are you sure you want to create series that are equal to the log of the original series? It is pretty rare that you would want to do that in EViews, since you can just use the expression log(x1) inline.
Re: Loop over all variables
Yes, because I would prefer to do it on that way than manually, it also looks more professional :D !! I will omit the transformation of certain variables, that are not needed to be logged, such as interest rates, though, all the others have to be transformed.
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13583
- Joined: Tue Sep 16, 2008 5:38 pm
Re: Loop over all variables
No, the point is that you don't need to create new series in EViews.
What are you going to do with all the transformed variables?
What are you going to do with all the transformed variables?
Re: Loop over all variables
I will try to regress them in my models. Each model has many specifications thus I will produce 50 models
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13583
- Joined: Tue Sep 16, 2008 5:38 pm
Re: Loop over all variables
So if you have variables Y, X1 and X2 and you want to estimate in logs, just use this as the estimation command:
You don't need to create the logged series themselves.
Code: Select all
ls log(y) c log(x1) log(x2)
Re: Loop over all variables
Thank you very much Gareth for the help. One last try on this issue...If I write something like:
group xs
for %i x1 x2 x3 x4 'up to 150
xs.add {%i}
next
for !i=1 to xs.@count
series x{!i}=log({!i})
next
EVIEWS creates 4 series and gives me log(1), log(2) and not log(x1), log(x2) etc.
If I change the code to
group xs
for %i x1 x2 x3 x4 'up to 150
xs.add {%i}
next
for !i=1 to xs.@count
series x{!i}=log({%i})
next
EVIEWS creates 4 series (as in my example I create only x1 x2 x3 x4), each one is identical to the other, and they are all equal to log(x4) ...ie the last variable of the group. What am I missing here?
group xs
for %i x1 x2 x3 x4 'up to 150
xs.add {%i}
next
for !i=1 to xs.@count
series x{!i}=log({!i})
next
EVIEWS creates 4 series and gives me log(1), log(2) and not log(x1), log(x2) etc.
If I change the code to
group xs
for %i x1 x2 x3 x4 'up to 150
xs.add {%i}
next
for !i=1 to xs.@count
series x{!i}=log({%i})
next
EVIEWS creates 4 series (as in my example I create only x1 x2 x3 x4), each one is identical to the other, and they are all equal to log(x4) ...ie the last variable of the group. What am I missing here?
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13583
- Joined: Tue Sep 16, 2008 5:38 pm
Re: Loop over all variables
Code: Select all
group xs
for %i x1 x2 x3 x4 'up to 150
xs.add {%i}
next
for !i=1 to xs.@count
series x{!i}=log(xs({!i}))
next
Re: Loop over all variables
Thank you very much!!!!
Who is online
Users browsing this forum: No registered users and 2 guests
