replace variables in a bunch of systems

For questions regarding programming in the EViews programming language.

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

309blank
Posts: 9
Joined: Mon Jan 04, 2016 6:48 am

replace variables in a bunch of systems

Postby 309blank » Thu Dec 08, 2016 7:46 am

What I have is a bunch of equation systems, and in order to clean them up and correct a consistent error in all of them I have written the following bit of code:

Code: Select all

for %sys {%system_list_3f} svector equations = {%sys}.@svectornb 'The lines of the system are here 'Create a temporary system for safety reasons system tempsys for !x=1 to (@rows(equations)) %equation = equations(!x) for !y=1 to (@wcount(%eq_3f_or)) 'replace the wrong parts of the equations %equation = @replace(%equation, @word(%eq_3f_or, !y), @word(%eq_3f_re, !y)) next 'append the corrected to tempsys tempsys.append {%equation} next {%sys}.@svectornb = tempsys.@svectornb next
Basically what it does is replace a bunch of expressions everywhere they occur in the equations, but I can't assign the correct equations to the original eq systems. How should I do that? Should I overwrite the systems completely because I will have to reestimate them anyways?

best regards,

309blank
Posts: 9
Joined: Mon Jan 04, 2016 6:48 am

Re: replace variables in a bunch of systems

Postby 309blank » Thu Dec 08, 2016 8:21 am

alright, I just went with the absolute tabula rasa method (obviously not before a backup), and this seems to work even if it's not very elegant:

Code: Select all

for %sys {%system_list_3f} svector equations = {%sys}.@svectornb 'The lines of the system are here %command = {%sys}.@command'The command to estimate the system delete {%sys} 'delete the original system 'Create a temporary system for safety reasons system tempsys system {%sys} for !x=1 to (@rows(equations)) %equation = equations(!x) for !y=1 to (@wcount(%eq_3f_or)) 'replace the wrong parts of the equations %equation = @replace(%equation, @word(%eq_3f_or, !y), @word(%eq_3f_re, !y)) next 'append the corrected to tempsys tempsys.append {%equation} {%sys}.append {%equation} next {%sys}.{%command} next


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 1 guest