multiple codes

For questions regarding programming in the EViews programming language.

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

vytama
Posts: 72
Joined: Wed Dec 19, 2012 11:05 am

multiple codes

Postby vytama » Thu May 28, 2015 9:49 am

Hello,

Eviews 8 here. I have multiple codes that I want to run with master code using exec function. It works fine. Each underlying code has a control variable for sample:

%t_smpl_beg="2015m1"
%t_smpl_end="2015m3"

The dates in the sample change and I need to change them individually in each underlying code. Is there a way to set this control in master code that runs underlying codes ? Then changes would be made once and they would apply to all codes? Thanks, Vytas

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

Re: multiple codes

Postby EViews Gareth » Thu May 28, 2015 9:57 am

Make them an argument or option in the executed program. You would then pass those variables on to the child programs as arguments/options.

vytama
Posts: 72
Joined: Wed Dec 19, 2012 11:05 am

Re: multiple codes

Postby vytama » Thu May 28, 2015 10:52 am

thank you. Do you have an example by any chance?

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

Re: multiple codes

Postby EViews Gareth » Thu May 28, 2015 10:56 am

The Program Arguments section of the EViews Programming chapter of the Command and Programming Reference has lots of examples of using program arguments.

Similarly the Program Options section of the EViews Programming chapter of the Command and Programming Reference has lots of examples of using program options.

vytama
Posts: 72
Joined: Wed Dec 19, 2012 11:05 am

Re: multiple codes

Postby vytama » Fri Jul 10, 2015 8:46 am

Hi,
I read your suggested material about program arguments and I cannot get it to run. Here is what I have with 2 arguments at the end as suggested in programming chapter:

%t_smpl_beg="2015m1"
%t_smpl_end="2015m3"
exec .\data_ger.prg" %t_smpl_beg %t_smpl_end

My child program gives me an error : error in sample: illegal date %t_smpl_beg

What am I doing wrong? Thanks.

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

Re: multiple codes

Postby EViews Gareth » Fri Jul 10, 2015 8:52 am

Hard to say without knowing what you're doing.

vytama
Posts: 72
Joined: Wed Dec 19, 2012 11:05 am

Re: multiple codes

Postby vytama » Fri Jul 10, 2015 10:43 am

Here is the part of the child program where I change sample. I have multiple programs for different countries. I have to go in each program and change control variable for sample: %t_smpl_beg and '%t_smpl_end. I also have master program that executes all child programs via exec command. What I am trying to achieve is to have the sample control variables in master exec program which would change all child samples.

%t_smpl_beg="2015m7"
'%t_smpl_end="2015m10"
for %1 "1" "4" "7"
!hor = {%1}
!horf = !hor+3

equation ols_{%1}.ls gdp_yoy c vemi(hor to -!horf) vlei(-!hor to -!horf) gdp_yoy(-!h_gdp)(-!hor to -!horf)

smpl %t_smpl_beg+!hor-1 %t_smpl_end+!hor-1

ols_{%1}.fit gdp_{%1}
smpl @all
next

I would like that exec .\data_ger.prg" %t_smpl_beg %t_smpl_end would apply control variables to child program above.
I hope this makes a bit more clear. Thanks

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

Re: multiple codes

Postby EViews Gareth » Fri Jul 10, 2015 12:09 pm

The smpl statements need to refer to the argument variables %0, %1 etc...


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 2 guests