Page 1 of 1

delete several series

Posted: Wed Jan 28, 2015 8:41 am
by YK_Econ
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

Re: delete several series

Posted: Wed Jan 28, 2015 9:01 am
by EViews Gareth

Code: Select all

delete *_nafta

Re: delete several series

Posted: Wed Jan 28, 2015 9:09 am
by YK_Econ
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!

Re: delete several series

Posted: Wed Jan 28, 2015 9:16 am
by EViews Gareth
You could put it in a for loop if you want.

Re: delete several series

Posted: Wed Jan 28, 2015 9:23 am
by YK_Econ
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!

Re: delete several series

Posted: Wed Jan 28, 2015 9:32 am
by EViews Gareth
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

Re: delete several series

Posted: Wed Feb 04, 2015 5:13 am
by YK_Econ
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

Re: delete several series

Posted: Wed Feb 04, 2015 9:02 am
by EViews Gareth
Just change the list of countries to delete to be the ones you want to delete.

Re: delete several series

Posted: Mon Feb 09, 2015 4:52 am
by YK_Econ
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

Re: delete several series

Posted: Mon Feb 09, 2015 8:30 am
by johansamuelsson

Code: Select all

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