Using strings when including or loading files

For questions regarding programming in the EViews programming language.

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

Jwink
Posts: 11
Joined: Thu Mar 17, 2011 12:44 pm

Using strings when including or loading files

Postby Jwink » Tue Oct 25, 2011 9:08 am

Working with Eviews 6

I'm running a fairly long program that is made up of a lot of smaller programs that are included in the original program file (using the include command). I have to run this program fairly frequently, either monthly or quarterly and I have to save the runs in separate files to keep track. I'd like to be able to replace all of the month and year parts of the included file names with a common string so that I just have to change it once and then it will update throughout the whole file. I got it to work on one of the individual included programs but not the main program and I can't figure out the difference.

The main program looks like:

%year = "11"
%month = "Sept"

load j:\revenue\model\JWink\11OctCon\Octcon11.wf1
read(b2, s=A) j:\revenue\model\Econdata\OctCON11.xls 200

include j:\revenue\model\Jwink\11SeptCon\varnames.prg
include j:\revenue\model\Jwink\11SeptCon\calcvar.prg

include j:\revenue\model\Jwink\11SeptCon\11SeptConSpools\bsernspool1.prg
include j:\revenue\model\Jwink\11SeptCon\11SeptConSpools\realnspool1.prg
include j:\revenue\model\Jwink\11SeptCon\11SeptConSpools\insurnspool1.prg
etc....

What I'd like to do is be able to replace each of those "11Oct" or "11Sept" with %year%month.

Each of the individual spool files - e.g. bsernspool1 - is made up of 3 individual programs 1 that calls another that calls another in sequence. Within those files I was able to set it up so that I could assign a string at the beginning and then call the files using those strings:

'Program for BANKN

'First input the variable you wish to test in the line below
%a = "bankn"

%month = "Sept"

%year = "11"

'1st - name your spool and create it:
%spool = %a+"spool"
spool {%spool}
{%spool}.options +displaynames
{%spool}.options +titles
'2nd - create any new variables or dummy variables &

'set sample start date
%smplstart="1990:1"

'set sample end date
%smplend="2011:2"

smpl 1990:1 1993:1
genr dumbkn = 0
smpl 1993:2 2003:4
genr dumbkn = 1
smpl 2004:1 2007:2
genr dumbkn = 0
smpl 2007:3 2017:4
genr dumbkn = 1
'2a - set your sample size *note need to adjust sample sizes with new runs
smpl %smplstart %smplend
'2b - create a seasonally adjusted version of your variable (not always necessary):
{%a}.x12(mode=m, filter=msr)

include "j:\revenue\model\Jwink\%year%monthCon\%year%monthConSpools\banknspool2.prg"

If there's some difference between the two operations or if there's a way to do this, I'd really appreciate it. (If there's a better way to set this up all together that'd be fine too).

-Thanks,
John

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

Re: Using strings when including or loading files

Postby EViews Gareth » Tue Oct 25, 2011 9:26 am

This can't be done in EViews 6.

The include command gets issued before anything else in the program. Thus it gets issued before any strings have been assigned, which means you can't use a string in the include command.

In EViews 7 you can use exec rather than include, which lets you use strings.

Jwink
Posts: 11
Joined: Thu Mar 17, 2011 12:44 pm

Re: Using strings when including or loading files

Postby Jwink » Tue Oct 25, 2011 9:35 am

Thanks Gareth,

I should have known that. You actually told me about the order of execution in a previous question. The thing that was throwing me off was that it was working in the smaller included files when I ran them independent of the larger file - I'm still not quite sure why that is.

-Thanks,
John


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 0 guests