Page 1 of 1
Number of observations in alpha series
Posted: Mon Sep 01, 2014 7:14 am
by ErikG
Hi,
I'm trying to get the number of observations in an alpha series but I keep getting the error message: Alpha sent to function which operates on a matrix:
WfCreate(wf=unstruct, page=test) u 10
Alpha aAlphaSeries = "A"
!iK = @Last(aAlphaSeries)
!iK = @Obs(aAlphaSeries)
/Erik.
Re: Number of observations in alpha series
Posted: Tue Sep 02, 2014 8:11 am
by EViews Gareth
Try alpha.@first or alpha.@last
Re: Number of observations in alpha series
Posted: Wed Sep 03, 2014 4:46 am
by ErikG
Hi,
It works but I must say the code could be improved.... I have an alpha series called "a" with 21 observations of which the 21st is empty/missing.
a.@first returns the string 21 - I would expect a string with the first observation
a.@last returns the string 20 - I would expect a string with the last observation, or an integer containing the index of the last non-missing observation
a.@obs returns 0 - I would like it to return the number of non-missing observations.
I am working in an unstructured/undated workfile, I guess it might work differently in a dated workfile.
/Erik.
Re: Number of observations in alpha series
Posted: Wed Sep 03, 2014 12:10 pm
by EViews Gareth
I can't replicate this. Could you post an example?
Re: Number of observations in alpha series
Posted: Thu Sep 04, 2014 3:36 am
by ErikG
Neither can I it seems for the @first function! I'm slightly confused now because I'm pretty sure it returned 21, but I guess I was mistaken.
Nevertheless @obs returns zero - as in the example below, but that's not a big problem, I'll just avoid that function when dealing with alphas.
Code: Select all
WfCreate(wf=unstruct, page=test) u 5
Alpha a
a(1) = "C"
a(2) = "D"
a(3) = "E"
a(4) = "F"
!obs = a.@obs
@UiPrompt(@Str(!obs))
Re: Number of observations in alpha series
Posted: Fri Sep 05, 2014 5:46 am
by ErikG
Hi again,
It would be nice if the @obs function did work, since @last will not give a currect number of non-missing observations if the alpha series has 'holes' in it.
/Erik.
Re: Number of observations in alpha series
Posted: Fri Sep 05, 2014 8:29 am
by EViews Gareth
I'll see that it gets added for the next version.
Re: Number of observations in alpha series
Posted: Fri Sep 05, 2014 9:17 am
by EViews Gareth
ok, I added support for the @obs data member on alpha series into EViews 8. Next patch should have it.
I'll also add support for the @obs() function for EViews 9.
Re: Number of observations in alpha series
Posted: Mon Sep 08, 2014 12:21 am
by ErikG
Great, thanks!
Re: Number of observations in alpha series
Posted: Thu Jun 15, 2017 6:20 pm
by bcchen
Hi,
One follow up question that is related: How do I store the number of observations of a alpha series as a series?
I tried:
series count=alpha.@obs
but the count shows all 0.
Any idea?
Thanks,
BC
Re: Number of observations in alpha series
Posted: Thu Jun 15, 2017 9:33 pm
by EViews Gareth
Code: Select all
create u 100
smpl if nrnd<1.5
alpha a = "hello world"
smpl @all
series count = a.@obs
show count