Page 1 of 1

What's the eviews equivalent of Excel's countif?

Posted: Thu Feb 01, 2018 4:00 pm
by miorinnovo
I want to know how many positive numbers are in a series. in Excel its a simple countif > o type formula. What would be the eviews equivalent?

Thanks!

Re: What's the eviews equivalent of Excel's countif?

Posted: Thu Feb 01, 2018 4:16 pm
by startz
@sum(x>0)

Re: What's the eviews equivalent of Excel's countif?

Posted: Fri Feb 02, 2018 8:06 am
by miorinnovo
Thanks but I'm not getting that to work.

I get this message:

NA found in matrix in "SCALAR TEST= @SUM(x>0)".

The sereies has some Nas, but even when I fill them in I get this error message:

Scalar sent to function which operates on a matrix in "SCALAR TEST=@SUM(x>0)".

Any ideas?

Thanks

Re: What's the eviews equivalent of Excel's countif?

Posted: Fri Feb 02, 2018 8:24 am
by startz
Not sure, but are you sure that X is a series as opposed to a vector or matrix?

Re: What's the eviews equivalent of Excel's countif?

Posted: Fri Feb 02, 2018 8:56 am
by EViews Gareth
You have to, unfortunately, do it in two steps.

Code: Select all

smpl if x1>0 scalar test = @obssmpl

Re: What's the eviews equivalent of Excel's countif?

Posted: Fri Feb 02, 2018 9:12 am
by miorinnovo
Thanks Gareth!

Re: What's the eviews equivalent of Excel's countif?

Posted: Fri Feb 02, 2018 9:22 am
by miorinnovo
Can I use this sample sample trick to replace outliers in a series with NAs? Say I want to remove the highest and lowest 5% of observations in a series can i put somehting in this blank space that would do that?

Code: Select all

smpl if x1>_____

Re: What's the eviews equivalent of Excel's countif?

Posted: Fri Feb 02, 2018 9:23 am
by startz
You certainly can, but look at the @replace function which might be easier.

Re: What's the eviews equivalent of Excel's countif?

Posted: Fri Feb 02, 2018 9:41 am
by miorinnovo
Im not familiar with the replace function but I found the following code which worked well. Thanks

Code: Select all

series y = @recode(@abs(x) < @quantile(@abs(x), .9), x, na)

Re: What's the eviews equivalent of Excel's countif?

Posted: Fri Feb 02, 2018 9:47 am
by startz
I meant @recode. So you're ahead of me.

Re: What's the eviews equivalent of Excel's countif?

Posted: Fri Feb 02, 2018 9:48 am
by miorinnovo
ah, ok. Thanks.