Page 1 of 1

Count of observations falling within a range

Posted: Thu Nov 21, 2019 11:10 am
by DBW
Hi there,

I was hoping for some help.

I have a large number of monthly time series, for which I've been trying to work out how to extract a count of the observations that sit within a given range for each month. To be more specific, they're all monthly percent changes in the various sub-components of the headline consumer price index and I wanted to count, for example, how many of those sit within the range +1% MoM to +1.5% MoM.

I thought I might be able to do it using @obsby but haven't had any success.

Any thoughts?

Thanks

Re: Count of observations falling within a range

Posted: Thu Nov 21, 2019 11:14 am
by EViews Gareth

Code: Select all

smpl if cpig>0.01 and cpig<0.015 scalar num = @obssmpl

Re: Count of observations falling within a range

Posted: Fri Nov 22, 2019 2:18 am
by DBW
Thanks for your reply, Gareth, but it hasn't done the trick.

I'm getting an error that '@OBSSMP is an illegal or reserved name in "SCALAR NUM = @OBSSMP" ' (I'm using Eviews 11).

Also (and, sorry, perhaps I wasn't clear enough in my original post), I want to return the number of observations within that range for each month, so the output is a timeseries rather than a scalar value.

Thanks for your help.

Re: Count of observations falling within a range

Posted: Fri Nov 22, 2019 8:16 am
by EViews Gareth

Code: Select all

alpha yearmonth = @datestr(@date, "YYYYMM") smpl if cpig>0.01 and cpig<0.015 series num = @obsby(cpig, yearmonth)