## Generating a time series variable as a function of the other variables

For questions regarding programming in the EViews programming language.

Moderators: EViews Gareth, EViews Jason, EViews Moderator

mbeckr18
Posts: 11
Joined: Mon Oct 28, 2013 10:37 am

### Generating a time series variable as a function of the other variables

Hello,
I am new to programming and I would need help with an equation.
My goal is to generate a new series (variable) for my time-series dataset. My dataset consists of 17 variables and 200 weeks.
The new series (diss) should represent the absolute difference between all my variables in week t and the variables in week t-1 to t-13 (in the last 13 weeks).
Thus, I have written the following code.
series dis = resid
for !i = 1 to 17
for !t = 1 to 13
distance = @sum(abs(Var{!i} - Var{!i}(-!t)))
next
next

However, this code only gives me a scalar. I am not sure how to tell eviews that I need a value for each week (starting in week 14). I would highly appreciate any help.
Thank you so much in advance.

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 11736
Joined: Tue Sep 16, 2008 5:38 pm

### Re: Generating a time series variable as a function of the other variables

Code: Select all

`series dis=0for !i=1 to 17for !t=1 to 13dis = dis+@abs(var{!i} - var{!i}(-!t))nextnext`

Not 100% certain what you want from your description, but that code does what I think you want.
Follow us on Twitter @IHSEViews

Return to “Programming”

### Who is online

Users browsing this forum: No registered users and 10 guests