Hello
I am using Eviews 8.1.
I have several groups, each of which contains about 20 time series per country. The last date for which these series have values varies (let's assume that the most recent data for any of the series in the first group is 2015m04). For series that do not have values for this date (ie, only through 2015m03), I would like to extrapolate (or "pull forward") the value of the last date for which data are available to the last date of the sample. This is shown in the attached excel file -- columns B-F are the raw data, and columns H-L ("transformed data") is what I am trying to do.
I get an error message at the line {%a}(!i) = {%a}(!i)(-1)
Syntax error in "GENR AUD_REAL(5) = AUD_REAL(5)(-1)
Obviously this is wrong but I do not know how to index the series in the group properly.
Any help would be much appreciated.
Thank you very much
Jeff
for %a aud cad zar
for !i=1 to {%a}.@count
%name = {%a}.@seriesname(!i)
%first = {%name}.@first
%last = {%name}.@last
smpl %first %last
'Note: %end in the next row is defined in the program previously, and I have confirmed that it is in fact the last date for which any of the series in the group has a value
if %last < %end then
scalar fill = @datediff(@dateval(%end),@dateval(%last),"mm")
if fill>0 then
for !x = 1 to fill
smpl %last+!x %last+!x
{%a}(!i) = {%a}(!i)(-1)
next
endif
endif
next
next
Change values for certain dates of series in a group
Moderators: EViews Gareth, EViews Moderator, EViews Jason, EViews Matt
Change values for certain dates of series in a group
- Attachments
-
- eviews20150221.xlsx
- (12.07 KiB) Downloaded 385 times
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13604
- Joined: Tue Sep 16, 2008 5:38 pm
Re: Change values for certain dates of series in a group
Change:
to be:
Code: Select all
{%a}(!i) = {%a}(!i)(-1)
Code: Select all
{%name} = {%name}(-1)
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13604
- Joined: Tue Sep 16, 2008 5:38 pm
Re: Change values for certain dates of series in a group
I'd be careful to ensure that %end is defined properly. From my interpretation of your original post, you want %end to change depending on which group you're in. I see nothing in the code that ensures this.
If you know that there are only NAs at the end of each series (i.e. no internal NAs), or they do have internal missings, but you want to fill in those too, your code can be simplified a bit:
If you know that there are only NAs at the end of each series (i.e. no internal NAs), or they do have internal missings, but you want to fill in those too, your code can be simplified a bit:
Code: Select all
for %a aud cad zar
for !i=1 to {%a}.@count
smpl @first {%end} 'I'm using your definition of %end
%name = {%a}.@seriesname(!i)
{%name} = @recode({%name}=na, {%name}(-1), {%name})
next
next
Re: Change values for certain dates of series in a group
Many things, it looks like this did the trick.
Who is online
Users browsing this forum: No registered users and 2 guests
