delete several series

For questions regarding programming in the EViews programming language.

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

YK_Econ
Posts: 36
Joined: Wed Jan 28, 2015 8:34 am

delete several series

Postby YK_Econ » Wed Jan 28, 2015 8:41 am

Hi all,

I have a workfile with oecd data for consumption and several other variables for about 25 countries.

Now I want to delete all series of nafta, g7 and so on.

They are named c_nafta, m_g7, irl_oecd_tot for example.

Therefore I am looking for a command, with which I can delete all series in my workfile that end with _nafta, _g7, _oecd_tot and so on.

I think the command is very simple, however I couldn't find it until now.

Thx, greets

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

Re: delete several series

Postby EViews Gareth » Wed Jan 28, 2015 9:01 am

Code: Select all

delete *_nafta

YK_Econ
Posts: 36
Joined: Wed Jan 28, 2015 8:34 am

Re: delete several series

Postby YK_Econ » Wed Jan 28, 2015 9:09 am

do I really have to write

delete *_nafta
delete *_g7
delete *_g20
delete *_oecd_tot
.
.
.

or is there a faster or lets say, more elegant way?

thanks in advance!

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

Re: delete several series

Postby EViews Gareth » Wed Jan 28, 2015 9:16 am

You could put it in a for loop if you want.

YK_Econ
Posts: 36
Joined: Wed Jan 28, 2015 8:34 am

Re: delete several series

Postby YK_Econ » Wed Jan 28, 2015 9:23 am

exactly, that's what I expected how it works.

unfortunately I am completely new to eviews and therefore have not a clear idea how loops are working. I have the feeling that they can rather change all variables within a certain group. I however would have to delete just certain series which are relatively random spread in the worksheet.

Apart from that, I would really appreciate a link or sth to a nice introduction to loops. what I found until now was really confusing.

ps. I would also need a command to rename all series from gdp_ to y_ , from cons_ to c_ , from exp_ to x , and so on. So obviously another loop, however I have no idea how to do that!

thanks in advance!

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

Re: delete several series

Postby EViews Gareth » Wed Jan 28, 2015 9:32 am

The Programming Chapter in the Command and Programming Reference has a pretty good discussion of loops.

In this case, just something like:

Code: Select all

for %j _nafta _g7 _g20 _oecd_tot delete *{%j} next

YK_Econ
Posts: 36
Joined: Wed Jan 28, 2015 8:34 am

Re: delete several series

Postby YK_Econ » Wed Feb 04, 2015 5:13 am

Hi Gareth!

I would have a follow up question on that. I realized that I actually need 8 countries out of 35. So is there a loop/program that deletes everything BUT _nafta _oecd_tot _aus .

I think that would be much more comfortable and elegant. Moreover I think it's more clearly when you can see which countries will be left instead of which countries are not interesting.

Thanks for your help!

Best
YK

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

Re: delete several series

Postby EViews Gareth » Wed Feb 04, 2015 9:02 am

Just change the list of countries to delete to be the ones you want to delete.

YK_Econ
Posts: 36
Joined: Wed Jan 28, 2015 8:34 am

Re: delete several series

Postby YK_Econ » Mon Feb 09, 2015 4:52 am

well my question would haven been, if there is a code which deletes every series but the countries I choose . In other words, I would like to create a loop, where I name just the countries (=single series) that I want to delete instead of naming the countries I want to delete.

thanks
YK

johansamuelsson
Posts: 165
Joined: Thu Mar 03, 2011 10:07 pm
Contact:

Re: delete several series

Postby johansamuelsson » Mon Feb 09, 2015 8:30 am

Code: Select all

%all = @WLookup("*","Series") %dontdelete = @WLookup("*_nafta *_oecd_tot *_aus","Series") %rest = @WDrop(%all,%dontdelete) Delete {%rest}
Regards Johan


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 2 guests