Donig the same operation for all the series in a workfile
Moderators: EViews Gareth, EViews Jason, EViews Moderator
Donig the same operation for all the series in a workfile
I've a workfile with hundreds of series imported. And I want to do the same operation (let's say to divide by 10) for all the series where their names have not a unique pattern. Is it possible under EViews 6 ?

 Fe ddaethom, fe welon, fe amcangyfrifon
 Posts: 11405
 Joined: Tue Sep 16, 2008 5:38 pm
Re: Donig the same operation for all the series in a workfile
With a bit of work, yep....
Code: Select all
group g * 'put every series in the workfile into a group
group g_new 'group to hold new series when created
for !i=1 to g.@count 'loop through every series in the first group
%name = g.@seriesname(!i) 'grab the current series name
series {%name}_new = {%name}/10 'create new series
g_new.add {%name}_new 'add it to the second group
next
Follow us on Twitter @IHSEViews
Re: Donig the same operation for all the series in a workfile
Very useful.
Thanks a lot.
Thanks a lot.
Re: Donig the same operation for all the series in a workfile
I have a question which is an extension of the original question  rather than grouping all the series in a workfile, is it possible to group a set of series in a workfile by an equation? Once it is grouped, in which order does it place the series  i.e. is the first series in the group the dependent variable? Basically I want to be able to group a particular equation and be able run some OLS regressions on the nondependent variables it contains. Please let me know if you need more information!

 Fe ddaethom, fe welon, fe amcangyfrifon
 Posts: 11405
 Joined: Tue Sep 16, 2008 5:38 pm
Re: Donig the same operation for all the series in a workfile
Unfortunately there is not a way, currently, to get information from an equation about which variables are used in that equation. This will change in EViews 7.
A workaround that sometimes is applicable is that you can estimate an equation with just a group as the list of regressors, and then you can ask the group the name of the variables it contains.
A workaround that sometimes is applicable is that you can estimate an equation with just a group as the list of regressors, and then you can ask the group the name of the variables it contains.
Follow us on Twitter @IHSEViews
Re: Donig the same operation for all the series in a workfile
Thanks! Can you clarify what you mean by "estimate an equation with just a group as the list of regressors, and then you can ask the group the name of the variables it contains." I haven't worked with groups much yet, but I am interpreting this to mean that, before estimating the equation the first time, you group the regressors, then you can both estimate the original equation and use the group to work with the regressors the series contains? Could you please provide a little sample code for this? Again, thank you so much for your help!

 Fe ddaethom, fe welon, fe amcangyfrifon
 Posts: 11405
 Joined: Tue Sep 16, 2008 5:38 pm
Re: Donig the same operation for all the series in a workfile
Sure. This code will work as a stand alone program.
However as has just been pointed out to me, you can actually do better than this. From an equation you can make a group of the variables that are in the equation. Then you can drop the first element (which would be the dependent variable), and then grab the series names from that group.
Code: Select all
create u 100
series y=nrnd
series x1=nrnd
series x2=nrnd
series x3=nrnd
series x4=nrnd
group regs c x1 x2 x3 x4
equation e1.ls y regs
table regressors
regressors(1,1) = regs.@seriesname(1)
regressors(1,2) = regs.@seriesname(2)
regressors(1,3) = regs.@seriesname(3)
regressors(1,4) = regs.@seriesname(4)
However as has just been pointed out to me, you can actually do better than this. From an equation you can make a group of the variables that are in the equation. Then you can drop the first element (which would be the dependent variable), and then grab the series names from that group.
Code: Select all
e1.makeregs regs
%name = regs.@seriesname(1)
regs.drop {%name}
table regressors
regressors(1,1) = regs.@seriesname(1)
regressors(1,2) = regs.@seriesname(2)
regressors(1,3) = regs.@seriesname(3)
regressors(1,4) = regs.@seriesname(4)
Follow us on Twitter @IHSEViews
Re: Donig the same operation for all the series in a workfile
Thanks so much! This was just what I needed.
Who is online
Users browsing this forum: No registered users and 4 guests