Page 1 of 1

Index problem in while loop

Posted: Fri Dec 16, 2016 2:17 pm
by morak5
Hi,

I have a vector j1 = [1 2 3, ..., 17] and a set of series labelled w_0, w_5, w_10, ..., w_80, and want to create a new series

jp1 = w_0*j1(1) + w_5*j1(2) + ... + w_80*j1(17)

The code below however, generates jp1 starting from !m=12 (!n=55), instead of !m=1. What am I doing wrong here? Thanks.

Code: Select all

scalar J= 17 ' Number of age groups between 0 to 80+ vector(J) j1 for !k = 1 to J j1(!k) = !k next series jp1 = 0 !m=0 while !m<17 !n = 5*!m !m = !m + 1 jp1 = w_{!n}*j1(!m) + jp1 wend

Re: Index problem in while loop

Posted: Fri Dec 16, 2016 2:28 pm
by EViews Gareth
Your code is correct. What makes you think it isn't?

Re: Index problem in while loop

Posted: Fri Dec 16, 2016 2:56 pm
by EViews Matt
If you're looking at the modification history shown within the series, be aware that it's limited to six lines. It's therefore normal that you would only see a record of the last six assignments within your loop, corresponding to !m = 12 through !m = 17.

Re: Index problem in while loop

Posted: Fri Dec 16, 2016 3:08 pm
by morak5
Ah, I see. Just checked the numbers and you are right. Many thanks, Matt, Gareth.