Donig the same operation for all the series in a workfile

For questions regarding programming in the EViews programming language.

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

oth76
Posts: 4
Joined: Mon Oct 13, 2008 3:22 am

Donig the same operation for all the series in a workfile

Postby oth76 » Mon Oct 13, 2008 4:48 am

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 ?

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

Re: Donig the same operation for all the series in a workfile

Postby EViews Gareth » Mon Oct 13, 2008 7:24 am

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

oth76
Posts: 4
Joined: Mon Oct 13, 2008 3:22 am

Re: Donig the same operation for all the series in a workfile

Postby oth76 » Mon Oct 13, 2008 9:45 am

Very useful.
Thanks a lot.

dhanssen
Posts: 35
Joined: Sun Oct 12, 2008 11:03 am

Re: Donig the same operation for all the series in a workfile

Postby dhanssen » Mon Oct 13, 2008 1:40 pm

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 non-dependent variables it contains. Please let me know if you need more information!

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

Re: Donig the same operation for all the series in a workfile

Postby EViews Gareth » Mon Oct 13, 2008 1:57 pm

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 work-around 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

dhanssen
Posts: 35
Joined: Sun Oct 12, 2008 11:03 am

Re: Donig the same operation for all the series in a workfile

Postby dhanssen » Mon Oct 13, 2008 4:44 pm

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!

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

Re: Donig the same operation for all the series in a workfile

Postby EViews Gareth » Mon Oct 13, 2008 4:55 pm

Sure. This code will work as a stand alone program.

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

dhanssen
Posts: 35
Joined: Sun Oct 12, 2008 11:03 am

Re: Donig the same operation for all the series in a workfile

Postby dhanssen » Tue Oct 14, 2008 7:42 am

Thanks so much! This was just what I needed.


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 24 guests