Page 1 of 1

Delete series with zero observations

Posted: Thu Feb 26, 2009 6:40 am
by javiersan
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

Re: Delete series with zero observations

Posted: Thu Feb 26, 2009 6:41 am
by javiersan
I mean

Code: Select all

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

Re: Delete series with zero observations

Posted: Thu Feb 26, 2009 7:00 am
by javiersan
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

Re: Delete series with zero observations

Posted: Thu Feb 26, 2009 9:17 am
by EViews Gareth
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

Re: Delete series with zero observations

Posted: Thu Feb 26, 2009 12:58 pm
by javiersan
Thanks Gareth, really appreciated.

Javier

Re: Delete series with zero observations

Posted: Fri Feb 27, 2009 10:44 am
by javiersan
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

Re: Delete series with zero observations

Posted: Fri Feb 27, 2009 10:52 am
by EViews Gareth
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

Re: Delete series with zero observations

Posted: Fri Feb 27, 2009 11:57 am
by javiersan
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

Re: Delete series with zero observations

Posted: Fri Feb 27, 2009 12:01 pm
by EViews Gareth
When you run a program, the run dialog lets you set the error threshold

Re: Delete series with zero observations

Posted: Fri Feb 27, 2009 12:07 pm
by javiersan
Oops... I've pressed the run botton hundreds of times and did not pay attention... Thanks.

Re: Delete series with zero observations

Posted: Fri Feb 27, 2009 12:21 pm
by javiersan
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

Re: Delete series with zero observations

Posted: Fri Feb 27, 2009 12:31 pm
by EViews Gareth
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.