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

For questions regarding programming in the EViews programming language.

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

miorinnovo
Posts: 199
Joined: Sun Mar 01, 2015 5:01 pm

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

Postby miorinnovo » Thu Feb 01, 2018 4:00 pm

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!

startz
Non-normality and collinearity are NOT problems!
Posts: 3775
Joined: Wed Sep 17, 2008 2:25 pm

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

Postby startz » Thu Feb 01, 2018 4:16 pm

@sum(x>0)

miorinnovo
Posts: 199
Joined: Sun Mar 01, 2015 5:01 pm

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

Postby miorinnovo » Fri Feb 02, 2018 8:06 am

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

startz
Non-normality and collinearity are NOT problems!
Posts: 3775
Joined: Wed Sep 17, 2008 2:25 pm

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

Postby startz » Fri Feb 02, 2018 8:24 am

Not sure, but are you sure that X is a series as opposed to a vector or matrix?

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

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

Postby EViews Gareth » Fri Feb 02, 2018 8:56 am

You have to, unfortunately, do it in two steps.

Code: Select all

smpl if x1>0
scalar test = @obssmpl
Follow us on Twitter @IHSEViews

miorinnovo
Posts: 199
Joined: Sun Mar 01, 2015 5:01 pm

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

Postby miorinnovo » Fri Feb 02, 2018 9:12 am

Thanks Gareth!

miorinnovo
Posts: 199
Joined: Sun Mar 01, 2015 5:01 pm

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

Postby miorinnovo » Fri Feb 02, 2018 9:22 am

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>_____   

startz
Non-normality and collinearity are NOT problems!
Posts: 3775
Joined: Wed Sep 17, 2008 2:25 pm

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

Postby startz » Fri Feb 02, 2018 9:23 am

You certainly can, but look at the @replace function which might be easier.

miorinnovo
Posts: 199
Joined: Sun Mar 01, 2015 5:01 pm

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

Postby miorinnovo » Fri Feb 02, 2018 9:41 am

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)

startz
Non-normality and collinearity are NOT problems!
Posts: 3775
Joined: Wed Sep 17, 2008 2:25 pm

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

Postby startz » Fri Feb 02, 2018 9:47 am

I meant @recode. So you're ahead of me.

miorinnovo
Posts: 199
Joined: Sun Mar 01, 2015 5:01 pm

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

Postby miorinnovo » Fri Feb 02, 2018 9:48 am

ah, ok. Thanks.


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 28 guests