Page 1 of 1

Recursive Problem in Integer-based loops

Posted: Mon Aug 26, 2013 8:12 am
by blonggovnl
Sorry for the confusing title to this thread. I have the following snippet of code:

for !i=2 to 12

genr gain_g{!i}_{%s}=g{!i}_{ %s}-g{!i-1}_{ %s}(-1)

next

where each gain_g!... series is previously created with NA values using "series". I want the loop to give them values as such:

gain_g2...=gain_g2-gain_g1...(-1).

However, specifying it as g{!i-1} gives me an error.

Any ideas?

Thanks,

BL

Re: Recursive Problem in Integer-based loops

Posted: Mon Aug 26, 2013 8:20 am
by EViews Gareth

Code: Select all

!j = !i-1 g{!j}

Re: Recursive Problem in Integer-based loops

Posted: Mon Aug 26, 2013 9:26 am
by blonggovnl
Hahaha clever. Thank you.