Delete series with zero observations

For questions regarding programming in the EViews programming language.

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

javiersan
Posts: 184
Joined: Mon Jan 19, 2009 8:18 am

Delete series with zero observations

Postby javiersan » Thu Feb 26, 2009 6:40 am

Hi,

I need to delete all series of an imported file where there are no observations, I have the code below that does not work. Coul you please help?

Code: Select all

group g *

for !i=1 to g.@count
if @obs(g(!i))  then delete g(!i)
next !i


Thanks,

Javier

javiersan
Posts: 184
Joined: Mon Jan 19, 2009 8:18 am

Re: Delete series with zero observations

Postby javiersan » Thu Feb 26, 2009 6:41 am

I mean

Code: Select all

group g *

for !i=1 to g.@count
if @obs(g(!i))=0  then delete g(!i)
next !i

javiersan
Posts: 184
Joined: Mon Jan 19, 2009 8:18 am

Re: Delete series with zero observations

Postby javiersan » Thu Feb 26, 2009 7:00 am

In fact my question is perhaps more generic and it is how to use the @errorcount function so that when one of the objects is alphanumeric it deletes the object.

Thanks,

Javier

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

Re: Delete series with zero observations

Postby EViews Gareth » Thu Feb 26, 2009 9:17 am

Something like:

Code: Select all

group g*

for !i=1 to g.@count
     !firstcount = @errorcount
     !temp = @max(g(!i))
     !secondcount = @errorcount
     if !firstcount<!secondcount then
          %name = g.@seriesname(!i)
          delete {%name}
     endif
next
Follow us on Twitter @IHSEViews

javiersan
Posts: 184
Joined: Mon Jan 19, 2009 8:18 am

Re: Delete series with zero observations

Postby javiersan » Thu Feb 26, 2009 12:58 pm

Thanks Gareth, really appreciated.

Javier

javiersan
Posts: 184
Joined: Mon Jan 19, 2009 8:18 am

Re: Delete series with zero observations

Postby javiersan » Fri Feb 27, 2009 10:44 am

Hi Gareth,

When running the program above I receive an error message like "Bad argument to function in "!TEMP=@MAX(G(1))"

Any clue as to why?

Thanks,

Javier

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

Re: Delete series with zero observations

Postby EViews Gareth » Fri Feb 27, 2009 10:52 am

Sometimes EViews programming can be frustrating....

Code: Select all

group g*

for !i=1 to g.@count
     !firstcount = @errorcount
     %name = g.@seriesname(!i)
     !temp = @max({%name})
     !secondcount = @errorcount
     if !firstcount<!secondcount then
          delete {%name}
     endif
next
Follow us on Twitter @IHSEViews

javiersan
Posts: 184
Joined: Mon Jan 19, 2009 8:18 am

Re: Delete series with zero observations

Postby javiersan » Fri Feb 27, 2009 11:57 am

Thanks, the program commands are now fine, unfortunately when an imported series has zero observations EViews defaults its type to "alpha" and gives the following error message: "Alpha [series name] sent to function which operates on a matrix "!TEMP=@MAX([series name])". My error threshold is probably 1, how do I increase it?

Regards,

Javier

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

Re: Delete series with zero observations

Postby EViews Gareth » Fri Feb 27, 2009 12:01 pm

When you run a program, the run dialog lets you set the error threshold
Follow us on Twitter @IHSEViews

javiersan
Posts: 184
Joined: Mon Jan 19, 2009 8:18 am

Re: Delete series with zero observations

Postby javiersan » Fri Feb 27, 2009 12:07 pm

Oops... I've pressed the run botton hundreds of times and did not pay attention... Thanks.

javiersan
Posts: 184
Joined: Mon Jan 19, 2009 8:18 am

Re: Delete series with zero observations

Postby javiersan » Fri Feb 27, 2009 12:21 pm

Actually, is there a way of increasing the error counter via a command in a program? Or can I only increase the counter manually when pressing run?

Thanks again,

Javier

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

Re: Delete series with zero observations

Postby EViews Gareth » Fri Feb 27, 2009 12:31 pm

You can only change it via the dialog, but note that you can change it permanently by selecting "make this the default execution mode", so that you won't have to change it every time you run the program.
Follow us on Twitter @IHSEViews


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 34 guests