Page 1 of 1

multiple codes

Posted: Thu May 28, 2015 9:49 am
by vytama
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

Re: multiple codes

Posted: Thu May 28, 2015 9:57 am
by EViews Gareth
Make them an argument or option in the executed program. You would then pass those variables on to the child programs as arguments/options.

Re: multiple codes

Posted: Thu May 28, 2015 10:52 am
by vytama
thank you. Do you have an example by any chance?

Re: multiple codes

Posted: Thu May 28, 2015 10:56 am
by EViews Gareth
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.

Re: multiple codes

Posted: Fri Jul 10, 2015 8:46 am
by vytama
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.

Re: multiple codes

Posted: Fri Jul 10, 2015 8:52 am
by EViews Gareth
Hard to say without knowing what you're doing.

Re: multiple codes

Posted: Fri Jul 10, 2015 10:43 am
by vytama
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

Re: multiple codes

Posted: Fri Jul 10, 2015 12:09 pm
by EViews Gareth
The smpl statements need to refer to the argument variables %0, %1 etc...