Recursive Problem in Integer-based loops

For questions regarding programming in the EViews programming language.

Moderators: EViews Gareth, EViews Moderator, EViews Jason, EViews Matt

blonggovnl
Posts: 16
Joined: Thu Aug 22, 2013 7:45 am

Recursive Problem in Integer-based loops

Postby blonggovnl » Mon Aug 26, 2013 8:12 am

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

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

Re: Recursive Problem in Integer-based loops

Postby EViews Gareth » Mon Aug 26, 2013 8:20 am

Code: Select all

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

blonggovnl
Posts: 16
Joined: Thu Aug 22, 2013 7:45 am

Re: Recursive Problem in Integer-based loops

Postby blonggovnl » Mon Aug 26, 2013 9:26 am

Hahaha clever. Thank you.


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 1 guest