Page 1 of 1

Change values for certain dates of series in a group

Posted: Thu May 21, 2015 3:28 pm
by Young
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

Re: Change values for certain dates of series in a group

Posted: Thu May 21, 2015 3:44 pm
by EViews Gareth
Change:

Code: Select all

{%a}(!i) = {%a}(!i)(-1)
to be:

Code: Select all

{%name} = {%name}(-1)

Re: Change values for certain dates of series in a group

Posted: Thu May 21, 2015 3:52 pm
by EViews Gareth
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:

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

Posted: Fri May 22, 2015 12:46 pm
by Young
Many things, it looks like this did the trick.