Count of observations falling within a range

For questions regarding the import, export and manipulation of data in EViews, including graphing and basic statistics.

Moderators: EViews Gareth, EViews Jason, EViews Steve, EViews Moderator

DBW
Posts: 9
Joined: Wed Jul 24, 2019 3:37 am

Count of observations falling within a range

Postby DBW » Thu Nov 21, 2019 11:10 am

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

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

Re: Count of observations falling within a range

Postby EViews Gareth » Thu Nov 21, 2019 11:14 am

Code: Select all

smpl if cpig>0.01 and cpig<0.015
scalar num = @obssmpl
Follow us on Twitter @IHSEViews

DBW
Posts: 9
Joined: Wed Jul 24, 2019 3:37 am

Re: Count of observations falling within a range

Postby DBW » Fri Nov 22, 2019 2:18 am

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.

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

Re: Count of observations falling within a range

Postby EViews Gareth » Fri Nov 22, 2019 8:16 am

Code: Select all

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


Return to “Data Manipulation”

Who is online

Users browsing this forum: No registered users and 19 guests