@elem gives an error message but should return the value of series at observation 85 (Eviews 8.1 Command Ref page 530)
workfile m 1995 2009
smpl 2001 2002
series a = nrnd
scalar value = @elem(a, "85")
@elem bug
Moderators: EViews Gareth, EViews Moderator
-
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13319
- Joined: Tue Sep 16, 2008 5:38 pm
Re: @elem bug
You can only enter the observation number if your workfile is undated. If your workfile is dated you need to enter the date.
Follow us on Twitter @IHSEViews
Re: @elem bug
A subroutine to obtain individual observations with structured data that is not dated is shown here in code with an example of how to use it
Code: Select all
WfCreate C:\temp\test.wf1 u 3
alpha code
Code(1) = "A"
Code(2) = "B"
Code(3) = "C"
series z = @obsnum
PageStruct() Code
Call getElem(z,"C",%Value)
Subroutine GetElem(series x, string %index, string %ReturnValue)
%IdSeries = @PageIds
if @wcount(%IdSeries) <> 1 Then
@uiprompt("Page must be structured with a single identifier, program aborted")
stop
endif
!iC = 0
for !i = 1 to @ObsRange
if {%IdSeries}(!i) = %index Then
%ReturnValue = @str(x(!i))
!iC = !iC + 1
endif
next
if !iC = 0 Then
@uiprompt("Warning the index " + %index + " does not exist")
endif
if !iC > 1 Then
@uiprompt("Warning: more than one occurerence of the index " + %index + " found, the last value is used")
endif
endsub
@uiprompt(%Value)
-
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13319
- Joined: Tue Sep 16, 2008 5:38 pm
Re: @elem bug
Nifty.
Slightly more efficient than using your for loop would be to set the sample and take the max of the series:
Slightly more efficient than using your for loop would be to set the sample and take the max of the series:
Code: Select all
smpl if {%idseries} = %index
%ReturnValue = @str(@max(x))
Follow us on Twitter @IHSEViews
Who is online
Users browsing this forum: No registered users and 31 guests