I amusing Eviews 9.5 Dec 16 built.
Two questions, both assuming that one is working with a panel workfile:
1) Is there a straightforward way of assigning the number of cross sectional units in a panel workpage to a scalar variable ?
2) Is there a straightforward approach of finding the date of the earliest non-missing value in a series for a specific cross sectional unit? One possible approach is implemented in the subroutine "getearliest" in the program listed below. However, it looks to me unnecessarily complicated. Any suggestion for a more straightforward approach much welcome.
Kind regards, mamo
Code: Select all
'create some data
wfcreate q 2000 2017 2
series x=nrnd
'create NAs in x until 2004Q3 for the 2nd cross sectional unit
smpl @first 2004Q3 if crossid=2
x=na
smpl @all
!notnadate=NA
'get the date of the earliest available non-mising value in x for the 2nd cross sectional unit
call getearliest(x, "crossid", "2", !notnadate)
'show in the statusline the earliest non-missing date for the 2nd cross sectional unit
%notnadate=@datestr(!notnadate, "YYYY[Q]Q")
statusline %notnadate
subroutine getearliest(series v, string %crossidentifier, string %cid, scalar !dat)
'gets the date of the earliest available non-mising value in v cross sectional unit labelled %cid
' in the series or alpha %crossidentifier identifying the cross secional units
'and writes into the string variable "%dat"
%oldsmpl=@pagesmpl
if {%crossidentifier}.@type="SERIES" then
smpl @all if {%crossidentifier}={%cid}
else
if {%crossidentifier}.@type="ALPHA" then
smpl @all if {%crossidentifier}=@stripquotes(%cid)
endif
endif
vector(1) _$ndates
series _$$ndates=@max(@cellid, @all)
stom(_$$ndates, _$ndates)
!t1=@ifirst(v)-(_$ndates(1)*(@floor(@ifirst(v)/_$ndates(1))))
delete _$ndates _$$ndates
series _$t2=@date(!t1-1)
vector(1) _$t3
stom(_$t2, _$t3)
!dat =_$t3(1)
delete _$t2 _$t3
smpl {%oldsmpl}
endsub